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

[Bug]: [langchain] missing api key #8497

Closed
ZaKull opened this issue Dec 11, 2023 · 2 comments
Closed

[Bug]: [langchain] missing api key #8497

ZaKull opened this issue Dec 11, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@ZaKull
Copy link

ZaKull commented Dec 11, 2023

Short description of current behavior

When I create an ML_ENGINE with langchain version 0.0.303, whether adding api_key, openai_api_key, or nothing, and then create a model using this ML_ENGINE, it returns an error indicating that the api_key or openai_api_key is missing.

I am using the staging branch in its latest version, and from this branch, I generate a docker as indicated by the mindsdb.Dockerfile.

[langchain_engine/tool_based_agent]: setup_tools() missing 1 required positional argument: 'openai_api_key'

[langchain_engine/tool_based_agent]: Missing API key api_key. Either re-create this ML_ENGINE specifying the api_key parameter, o[langchain_engine/tool_based_agent]: Missing API key api_key. Either re-create this ML_ENGINE specifying the api_key parameter, or re-create this model and pass the API key with USING syntax.r re-create this model and pass the API key with USING syntax.

Video or screenshots

Screenshot 2023-12-11 084729
Screenshot 2023-12-11 105816

Expected behavior

It is expected that by entering the openai api_key either in the ML_ENGINE or in the MODEL, it will not give an error that either openai_api_key or api_key is missing.

How to reproduce the error

CREATE ML_ENGINE langchain_engine
FROM langchain
USING
    api_key  ='sk-xxxxx';

DROP MODEL tool_based_agent;

CREATE MODEL tool_based_agent
PREDICT completion
USING
    engine = 'langchain_engine',
    api_key  ='sk-xxxxx',
    model_name = 'gpt-3.5-turbo',
    prompt_template = 'Answer the users input in a helpful way: {{input}}';

DESCRIBE tool_based_agent;

SELECT input, completion
FROM tool_based_agent
WHERE input = 'Could you describe the `mysql_demo_db.house_sales` table please?'
USING
    verbose = True,
    tools = [],
    max_iterations = 10;`
CREATE ML_ENGINE langchain_engine
FROM langchain
USING
    api_key  ='sk-xxxxx',
    openai_api_key  ='sk-xxxxx';

DROP MODEL tool_based_agent;

CREATE MODEL tool_based_agent
PREDICT completion
USING
    engine = 'langchain_engine',
    api_key  ='sk-xxxxx',
    openai_api_key  ='sk-xxxxx',
    model_name = 'gpt-3.5-turbo',
    prompt_template = 'Answer the users input in a helpful way: {{input}}';

DESCRIBE tool_based_agent;

SELECT input, completion
FROM tool_based_agent
WHERE input = 'Could you describe the `mysql_demo_db.house_sales` table please?'
USING
    verbose = True,
    tools = [],
    max_iterations = 10;

Anything else?

No response

@ZaKull ZaKull added the bug Something isn't working label Dec 11, 2023
@ZaKull
Copy link
Author

ZaKull commented Dec 11, 2023

2023-12-11 11:27:26 The above exception was the direct cause of the following exception:
2023-12-11 11:27:26 
2023-12-11 11:27:26 Traceback (most recent call last):
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/integrations/libs/ml_exec_base.py", line 283, in predict
2023-12-11 11:27:26     predictions = task.result()
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 458, in result
2023-12-11 11:27:26     return self.__get_result()
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
2023-12-11 11:27:26     raise self._exception
2023-12-11 11:27:26 RuntimeError: setup_tools() missing 1 required positional argument: 'openai_api_key'
2023-12-11 11:27:26 
2023-12-11 11:27:26 The above exception was the direct cause of the following exception:
2023-12-11 11:27:26 
2023-12-11 11:27:26 Traceback (most recent call last):
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/api/http/namespaces/sql.py", line 47, in post
2023-12-11 11:27:26     result = mysql_proxy.process_query(query)
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/utilities/profiler/profiler.py", line 138, in wrapper
2023-12-11 11:27:26     result = function(*args, **kwargs)
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/api/mysql/mysql_proxy/mysql_proxy.py", line 525, in process_query
2023-12-11 11:27:26     executor.query_execute(sql)
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/utilities/profiler/profiler.py", line 138, in wrapper
2023-12-11 11:27:26     result = function(*args, **kwargs)
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/api/mysql/mysql_proxy/executor/executor.py", line 115, in query_execute
2023-12-11 11:27:26     self.do_execute()
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/utilities/profiler/profiler.py", line 138, in wrapper
2023-12-11 11:27:26     result = function(*args, **kwargs)
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/api/mysql/mysql_proxy/executor/executor.py", line 212, in do_execute
2023-12-11 11:27:26     ret = self.command_executor.execute_command(self.query)
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/utilities/profiler/profiler.py", line 138, in wrapper
2023-12-11 11:27:26     result = function(*args, **kwargs)
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/api/mysql/mysql_proxy/executor/executor_commands.py", line 619, in execute_command
2023-12-11 11:27:26     query = SQLQuery(statement, session=self.session)
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/api/mysql/mysql_proxy/classes/sql_query.py", line 460, in __init__
2023-12-11 11:27:26     self.execute_query()
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/api/mysql/mysql_proxy/classes/sql_query.py", line 690, in execute_query
2023-12-11 11:27:26     raise e
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/api/mysql/mysql_proxy/classes/sql_query.py", line 684, in execute_query
2023-12-11 11:27:26     data = self.execute_step(step, steps_data)
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/api/mysql/mysql_proxy/classes/sql_query.py", line 873, in execute_step
2023-12-11 11:27:26     predictions = project_datanode.predict(
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/api/mysql/mysql_proxy/datahub/datanodes/project_datanode.py", line 66, in predict
2023-12-11 11:27:26     return handler.predict(model_name, data, project_name=self.project.name, version=version, params=params)
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/utilities/profiler/profiler.py", line 138, in wrapper
2023-12-11 11:27:26     result = function(*args, **kwargs)
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/utilities/functions.py", line 71, in wrapper
2023-12-11 11:27:26     return func(*args, **kwargs)
2023-12-11 11:27:26   File "/usr/local/lib/python3.10/site-packages/mindsdb/integrations/libs/ml_exec_base.py", line 289, in predict
2023-12-11 11:27:26     raise MLEngineException(msg) from e
2023-12-11 11:27:26 mindsdb.integrations.libs.ml_exec_base.MLEngineException: [langchain_engine/tool_based_agent]: setup_tools() missing 1 required positional argument: 'openai_api_key'

@ZaKull
Copy link
Author

ZaKull commented Dec 11, 2023

this commit fix this

58d92fc

@ZaKull ZaKull closed this as completed Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant