{"id":17593712,"url":"https://github.com/vbandi/rxai","last_synced_at":"2025-10-06T09:59:17.755Z","repository":{"id":258581859,"uuid":"871187133","full_name":"vbandi/RxAI","owner":"vbandi","description":"The RX.Net Way to AI","archived":false,"fork":false,"pushed_at":"2025-05-11T14:13:27.000Z","size":50,"stargazers_count":20,"open_issues_count":9,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-11T15:25:10.528Z","etag":null,"topics":["ai","azure","openai","rxnet"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vbandi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-11T12:50:32.000Z","updated_at":"2025-04-30T17:25:12.000Z","dependencies_parsed_at":"2025-04-20T09:17:07.686Z","dependency_job_id":null,"html_url":"https://github.com/vbandi/RxAI","commit_stats":null,"previous_names":["vbandi/rxai"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vbandi/RxAI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbandi%2FRxAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbandi%2FRxAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbandi%2FRxAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbandi%2FRxAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vbandi","download_url":"https://codeload.github.com/vbandi/RxAI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbandi%2FRxAI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278591270,"owners_count":26012029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","azure","openai","rxnet"],"created_at":"2024-10-22T06:12:37.177Z","updated_at":"2025-10-06T09:59:17.724Z","avatar_url":"https://github.com/vbandi.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RxAI: the RX.Net way to AI\n\nRxAI is a C# library that provides a reactive programming interface for interacting with OpenAI and Azure Realtime API. It simplifies the process of creating real-time, interactive AI-powered applications using Reactive Extensions (Rx).\n\n## Features\n\n- Use the Realtime API from OpenAI and Azure OpenAI with a reactive (RX.Net) programming model\n- Real-time conversation capabilities with audio input and output\n- Function calling support for extending AI capabilities\n- Built-in cost tracking and management\n- Customizable conversation options\n\n![image](https://github.com/user-attachments/assets/d256131f-f3c6-4fef-b596-0754458ef7de)\n\n\n## Project Structure\n\nThe RxAI solution consists of two main projects:\n\n1. **RxAI.Realtime**: This is the core library project that contains the main functionality for interacting with OpenAI and Azure Realtime API. It includes the `RealtimeConversationClientRX` class, which provides the reactive interface for AI conversations, as well as supporting classes for function calling and other utilities.\n\n2. **RxAI.ConsoleDemo**: This is a console application project that demonstrates how to use the RxAI.Realtime library. It provides a working example of setting up and running an interactive AI conversation with audio input and output, custom function calling, and cost tracking.\n\n## Installation\n\nTo use RxAI in your project, you need to:\n\n1. Clone this repository\n2. Add a reference to the RxAI.Realtime project in your solution\n3. Install the required NuGet packages (OpenAI, System.Reactive, etc.)\n\n## Running the Demo\n\nTo run the RxAI.ConsoleDemo and interact with the AI:\n\n### Using Visual Studio\n\n1. Set your OpenAI API key as an environment variable named `OPENAI_API_KEY`. This must be done before launching Visual Studio.\n   - On Windows: Open Command Prompt and run `setx OPENAI_API_KEY your_api_key_here`\n   - On macOS/Linux: Add `export OPENAI_API_KEY=your_api_key_here` to your shell profile file (e.g., ~/.bash_profile, ~/.zshrc)\n2. Open the src/CSharp/RxAI.sln solution file in Visual Studio.\n3. Set the src/CSharp/RxAI.ConsoleDemo project as the startup project.\n4. Press F5 or click \"Start Debugging\" to run the demo.\n\n### Using Command Line\n\n1. Navigate to the src/CSharp/RxAI.ConsoleDemo project directory in your terminal.\n2. Set your OpenAI API key as an environment variable:\n   - On Windows: `set OPENAI_API_KEY=your_api_key_here`\n   - On macOS/Linux: `export OPENAI_API_KEY=your_api_key_here`\n3. Run the following commands:\n   ```\n   dotnet build\n   dotnet run\n   ```\n\nOnce the demo is running, you can interact with the AI using your microphone for input and speakers for output. The console will display transcriptions, function calls, and cost information.\n\n### Tips\n- To exercise the demo's function calling capabilities, try saying: \"Add two random numbers\". This will demonstrate how the AI can use the custom Calculator functions to perform operations.\n- Avoid feedback loops by muting your speakers or using headphones to prevent the AI's output from being picked up by the microphone.\n\n## Usage\n\nHere's a simple example of how to use RxAI to create an interactive AI conversation:\n\n```csharp\nusing System.Text;\nusing OpenAI.RealtimeConversation;\nusing RxAI.Realtime.FunctionCalling;\nusing RxAI.Realtime;\n\n// Set up the OpenAI API key\nstring? openAIKey = Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\");\n\nif (string.IsNullOrEmpty(openAIKey))\n{\n    Console.WriteLine(\"Please set the OPENAI_API_KEY environment variable.\");\n    return;\n}\n\n// Create a conversation client\nRealtimeConversationClientRX conversation = RealtimeConversationClientRX.FromOpenAIKey(openAIKey);\n\n// Set up conversation options\nConversationSessionOptions options = new()\n{\n    Instructions = \"You are an annoyingly rude assistant. Use lots of sarcasm and emojis.\",\n    InputTranscriptionOptions = new() { Model = ConversationTranscriptionModel.Whisper1 },\n};\n\n// Initialize the conversation with custom functions\nvar calculator = new Calculator();\nawait conversation.InitializeSessionAsync(options, FunctionCallingHelper.GetFunctionDefinitions(calculator));\n\n// Subscribe to various events\nconversation.InputTranscriptionFinishedUpdates.Subscribe(t =\u003e Console.WriteLine(t.Transcript));\nconversation.OutputTranscriptionDeltaUpdates.Subscribe(u =\u003e Console.Write(u.Delta));\nconversation.FunctionCallStarted.Subscribe(f =\u003e Console.WriteLine($\"Function call: {f.Name}({f.Arguments})\"));\nconversation.FunctionCallFinished.Subscribe(f =\u003e Console.WriteLine($\"Function call finished: {f.result}\"));\n\n// Set up cost tracking\nconversation.SetupCost(5f / 1_000_000, 20f / 1_000_000, 100f / 1_000_000, 200f / 1_000_000);\nconversation.TotalCost.Subscribe(c =\u003e Console.WriteLine($\"Total cost: {c}\"));\n\n// Set up audio input and output\nSpeakerOutput speakerOutput = new();\nconversation.AudioDeltaUpdates.Subscribe(d =\u003e speakerOutput.EnqueueForPlayback(d.Delta));\n\nMicrophoneAudioStream microphone = MicrophoneAudioStream.Start();\nawait conversation.SendAudioAsync(microphone);\n\n// Start the conversation\nawait conversation.StartResponseTurnAsync();\n\nConsole.WriteLine(\"Starting conversation...\");\n\nwhile (true)\n{\n    await Task.Delay(10);\n}\n\n// Custom function definitions\npublic class Calculator\n{\n    [FunctionDescription(\"Get a random number within a specified range\")]\n    public static int GetRandomNumber(\n        [ParameterDescription(\"min\")] int min,\n        [ParameterDescription(\"max\")] int max)\n    {\n        return new Random().Next(min, max);\n    }\n\n    [FunctionDescription(\"Add two numbers together\")]\n    public static int Add(\n        [ParameterDescription(\"The first number to add\")] int a,\n        [ParameterDescription(\"The second number to add\")] int b)\n    {\n        return a + b;\n    }\n}\n```\n\n## How It Works\n\n1. The code sets up a `RealtimeConversationClientRX` using an OpenAI API key.\n2. Conversation options are configured, including custom instructions for the AI.\n3. The conversation is initialized with custom functions (a Calculator in this example).\n4. Various event subscriptions are set up to handle transcription updates, function calls, and cost tracking.\n5. Audio input (microphone) and output (speaker) are configured for real-time interaction.\n6. The conversation is started, allowing for continuous interaction with the AI.\n\nThis example demonstrates the simplicity and power of using RxAI to create interactive AI applications with real-time audio capabilities and custom function support.\n\n## License\n\n[MIT License](LICENSE)\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvbandi%2Frxai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvbandi%2Frxai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvbandi%2Frxai/lists"}