You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I searched the LangChain documentation with the integrated search.
I used the GitHub search to find a similar question and didn't find it.
Example Code
I want to create an OpenAI assistant using an existing ID, but I'm encountering an error.
assistant = OpenAIAssistantRunnable(assistant_id='assistant_id', as_agent=True) openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
assistant = OpenAIAssistantRunnable(assistant_id='assistant_id', as_agent=True, client=openai.OpenAI(api_key=self.model.openai_api_key)) pydantic.v1.errors.ConfigError: field "client" not yet prepared, so the type is still a ForwardRef. You might need to call OpenAIAssistantRunnable.update_forward_refs()
In both cases, an error is encountered. The only successful scenario is when the openai_api_key is set in the environment, but my requirement is for the user to provide it. Has anyone else faced a similar issue? Any assistance would be appreciated.
Description
OpenAIAssistantRunnable raise exception when pass client. There should be a way to pass the key from outside
System Info
langchain==0.1.0
Related Components
LLMs/Chat Models
Embedding Models
Prompts / Prompt Templates / Prompt Selectors
Output Parsers
Document Loaders
Vector Stores / Retrievers
Memory
Agents / Agent Executors
Tools / Toolkits
Chains
Callbacks/Tracing
Async
The text was updated successfully, but these errors were encountered:
I appreciate your interest in contributing to LangChain! It's great to see your enthusiasm for finding a solution to the issue with passing the client key from outside. Your efforts to address this problem are valuable to the community.
If you have a proposed solution or fix in mind, I encourage you to go ahead and create a pull request. Your contribution will help improve LangChain for all users. Thank you for your willingness to contribute!
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
dosubotbot
added
Ɑ: agent
Related to agents module
🤖:bug
Related to a bug, vulnerability, unexpected error with an existing feature
labels
Jan 12, 2024
…16486)
- **Description:** This addresses the issue tagged below where if you
try to pass your own client when creating an OpenAI assistant, a
pydantic error is raised:
Example code:
```python
import openai
from langchain.agents.openai_assistant import OpenAIAssistantRunnable
client = openai.OpenAI()
interpreter_assistant = OpenAIAssistantRunnable.create_assistant(
name="langchain assistant",
instructions="You are a personal math tutor. Write and run code to answer math questions.",
tools=[{"type": "code_interpreter"}],
model="gpt-4-1106-preview",
client=client
)
```
Error:
`pydantic.v1.errors.ConfigError: field "client" not yet prepared, so the
type is still a ForwardRef. You might need to call
OpenAIAssistantRunnable.update_forward_refs()`
It additionally updates type hints and docstrings to indicate that an
AzureOpenAI client is permissible as well.
- **Issue:** #15948
- **Dependencies:** N/A
Checked other resources
Example Code
I want to create an OpenAI assistant using an existing ID, but I'm encountering an error.
openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
pydantic.v1.errors.ConfigError: field "client" not yet prepared, so the type is still a ForwardRef. You might need to call OpenAIAssistantRunnable.update_forward_refs()
In both cases, an error is encountered. The only successful scenario is when the openai_api_key is set in the environment, but my requirement is for the user to provide it. Has anyone else faced a similar issue? Any assistance would be appreciated.
Description
OpenAIAssistantRunnable raise exception when pass client. There should be a way to pass the key from outside
System Info
langchain==0.1.0
Related Components
The text was updated successfully, but these errors were encountered: