Skip to content
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

Sweep: create a chat function like completion in upsonic_on_prem/utils/ai/ai.py #87

Open
2 tasks done
onuratakan opened this issue Mar 13, 2024 · 1 comment
Open
2 tasks done
Labels

Comments

@onuratakan
Copy link
Member

onuratakan commented Mar 13, 2024

Checklist
  • Modify upsonic_on_prem/utils/ai/ai.py80d2fda Edit
  • Running GitHub Actions for upsonic_on_prem/utils/ai/ai.pyEdit
@onuratakan
Copy link
Member Author

onuratakan commented Mar 13, 2024

🚀 Here's the PR! #88

See Sweep's progress at the progress dashboard!
💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: None)

Tip

I can email you next time I complete a pull request if you set up your email here!


Actions (click)

  • ↻ Restart Sweep

Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description.

https://github.com/Upsonic/On-Prem/blob/32357642dd961fdf0b6cc8d56ee91eff372ce0a2/upsonic_on_prem/utils/ai/ai.py#L1-L397


Step 2: ⌨️ Coding

  • Modify upsonic_on_prem/utils/ai/ai.py80d2fda Edit
Modify upsonic_on_prem/utils/ai/ai.py with contents:
• Add a new method named `chat` in the `AI_` class within the `ai.py` file. This method should closely resemble the structure of the `completion` method but be specifically designed for chat interactions.
• The `chat` method should accept two parameters: `input_text` (the user's input text for the chat) and `model` (the model to use for generating the chat response, with a default value of "gpt-3.5-turbo").
• Inside the `chat` method, use the `gpt` method to send the `input_text` to the specified model and return the response. This leverages the existing infrastructure for interacting with AI models and ensures consistency in how models are utilized across the module.
• Example method signature: `def chat(self, input_text, model="gpt-3.5-turbo"):`
• Inside the `chat` method, construct the request to the model in a manner that is suitable for chat interactions. This may involve setting up the `input_text` as part of a conversation context if the model supports such a format.
• Return the response from the model directly or format it as needed before returning to the caller.
• Ensure that the method includes error handling, similar to other methods in the `AI_` class, to gracefully manage any issues that arise during the interaction with the model.
--- 
+++ 
@@ -395,4 +395,11 @@
 
         return result
 
+    def chat(self, input_text, model="gpt-3.5-turbo"):
+        try:
+            return self.gpt(input_text, model=model)
+        except Exception as e:
+            failed(f"Failed to generate chat response: {e}")
+            return None
+
 AI = AI_()
  • Running GitHub Actions for upsonic_on_prem/utils/ai/ai.pyEdit
Check upsonic_on_prem/utils/ai/ai.py with contents:

Ran GitHub Actions for 80d2fda59906c473dcf52e06587a74d1b4439172:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/create_a_chat_function_like_completion_i.


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description.
Something wrong? Let us know.

This is an automated message generated by Sweep AI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant