-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AI communication interface #653
Conversation
Add AI interaction capability to the web interface. * **AgentDocs/AssistantFileSearch/Program.cs** - Add `HandleAIInteraction` method to handle AI interactions via a web interface. - Integrate the method with the existing logic and use `OpenAIAssistantAgent` for AI communication. * **app.py** - Add an endpoint `/ai-interact` to interact with the AI using the method from `AgentDocs/AssistantFileSearch/Program.cs`. - Ensure the endpoint handles POST requests and returns AI responses in JSON format. * **config.json** - Add configuration settings for AI interaction, such as API keys and endpoints.
Reviewer's Guide by SourceryThis pull request introduces an AI interaction feature to the web application. It leverages OpenAIAssistantAgent for communication and adds necessary configurations, endpoints, and handling logic. Sequence diagram for AI interaction flowsequenceDiagram
actor User
participant Web as Web Interface
participant AI as AI Handler
participant OpenAI as OpenAI Assistant
participant Store as Vector Store
User->>Web: POST /ai-interact
Web->>AI: HandleAIInteraction(userInput)
AI->>Store: CreateVectorStore()
AI->>OpenAI: UploadFiles()
AI->>OpenAI: CreateAssistant()
AI->>OpenAI: CreateThread()
AI->>OpenAI: AddChatMessage(threadId, userInput)
AI->>OpenAI: InvokeStreaming(threadId)
OpenAI-->>AI: Stream response chunks
AI-->>Web: Formatted response
Web-->>User: JSON response
Class diagram for AI interaction componentsclassDiagram
class Program {
+HandleAIInteraction(string userInput) Task<string>
}
class AIRequest {
+string user_input
}
class FastAPIApp {
+greet_json()
+ai_interact(Request, AIRequest) async
}
class OpenAIAssistantAgent {
+CreateAsync()
+CreateThreadAsync()
+AddChatMessageAsync()
+InvokeStreamingAsync()
+DeleteThreadAsync()
+DeleteAsync()
}
FastAPIApp ..> Program: uses
FastAPIApp ..> AIRequest: uses
Program ..> OpenAIAssistantAgent: uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Bryan-Roe - I've reviewed your changes - here's some feedback:
Overall Comments:
- The HandleAIInteraction method should use a try-finally block from the start of resource creation to ensure proper cleanup in all scenarios, not just successful execution paths.
- The /ai-interact endpoint needs request validation and rate limiting to prevent abuse and control costs.
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
* **AgentDocs/AssistantCodeInterpreter/AssistantCodeInterpreter.csproj** - Fix formatting issue by removing an extra character at the beginning of the file * **AgentDocs/AssistantFileSearch/AssistantFileSearch.csproj** - Fix formatting issue by adding a newline at the end of the file
Add AI interaction capability to the web interface.
AgentDocs/AssistantFileSearch/Program.cs
HandleAIInteraction
method to handle AI interactions via a web interface.OpenAIAssistantAgent
for AI communication.app.py
/ai-interact
to interact with the AI using the method fromAgentDocs/AssistantFileSearch/Program.cs
.config.json
Summary by Sourcery
New Features:
/ai-interact
endpoint.