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

calling a pre-defined openAI assistant #152

Open
ilikerobots opened this issue Jul 11, 2024 · 4 comments
Open

calling a pre-defined openAI assistant #152

ilikerobots opened this issue Jul 11, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@ilikerobots
Copy link

If I've already built an assistant in OpenAI, is it possible to use it for messages with django-ai-assistant?

@ilikerobots ilikerobots changed the title calling a pre-defined openAI assistatn calling a pre-defined openAI assistant Jul 11, 2024
@fjsj
Copy link
Member

fjsj commented Jul 11, 2024

Hi @ilikerobots , how is your assistant built? You mean an Assistant created via the OpenAI API? Or a Langchain agent?

If a Langchain agent, you can override methods like get_llm to provide the existing agent chain: https://vintasoftware.github.io/django-ai-assistant/latest/reference/assistants-ref/#django_ai_assistant.helpers.assistants.AIAssistant.get_llm

I believe Langchain can also use existing OpenAI API assistants. But we would have to check the docs on how to build a chain that uses the existing assistant. See: https://python.langchain.com/v0.1/docs/modules/agents/agent_types/openai_assistants/#using-existing-assistant

Then you can get the existing assistant and perhaps replace agent declaration here:

def as_chain(self, thread_id: Any | None) -> Runnable[dict, dict]:

You can do that by inheriting from AIAssistant and overriding as_chain.

@ilikerobots
Copy link
Author

@fjsj , appreciate the comments. I did mean a pre-defined OpenAI assistant, not a langchain agent. I'll look into this, but langchain is all new to me so it's taking a while. Feel free to close.

@ilikerobots
Copy link
Author

(btw, great job to those involved in this project: i'm deploying a help desk response assistant today using this)

@fjsj
Copy link
Member

fjsj commented Jul 12, 2024

Awesome @ilikerobots, thanks!
We plan to support pre-defined OpenAI assistants, so I will leave the issue open for now.

At least some documentation about this is necessary, if we don't change the library. But we may be able to do some matching via assistant ID and ensure we're using the pre-defined assistant from OpenAI.

@fjsj fjsj added the enhancement New feature or request label Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants