-
Notifications
You must be signed in to change notification settings - Fork 43
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
Python runtime does not work with OpenAI compatible endpoints #129
Comments
cc @sethjuarez We are using prompty pointing to Groq, and it works fine in the VS Extension, but it doesnt work with python runtime. |
I got it work with all these changes: diff --git a/runtime/prompty/prompty/cli.py b/runtime/prompty/prompty/cli.py
index 3f449d8..10e7862 100644
--- a/runtime/prompty/prompty/cli.py
+++ b/runtime/prompty/prompty/cli.py
@@ -32,6 +32,8 @@ def dynamic_import(module: str):
t = "prompty.azure"
elif module == "serverless":
t = "prompty.serverless"
+ elif module == "openai":
+ t = "prompty.openai"
else:
t = module
diff --git a/runtime/prompty/prompty/openai/__init__.py b/runtime/prompty/prompty/openai/__init__.py
index 57607a4..d7cd6cf 100644
--- a/runtime/prompty/prompty/openai/__init__.py
+++ b/runtime/prompty/prompty/openai/__init__.py
@@ -4,7 +4,7 @@ from prompty.invoker import InvokerException
try:
from .executor import OpenAIExecutor
from .processor import OpenAIProcessor
-except ImportError:
+except ImportError as e:
raise InvokerException(
- "Error registering OpenAIExecutor and OpenAIProcessor", "openai"
+ f"Error registering OpenAIExecutor and OpenAIProcessor: {e}", "openai"
)
diff --git a/runtime/prompty/prompty/openai/executor.py b/runtime/prompty/prompty/openai/executor.py
index 1b8f79a..003472c 100644
--- a/runtime/prompty/prompty/openai/executor.py
+++ b/runtime/prompty/prompty/openai/executor.py
@@ -18,12 +18,12 @@ class OpenAIExecutor(Invoker):
self.kwargs = {
key: value
for key, value in self.prompty.model.configuration.items()
- if key != "type"
+ if key != "type" and key != "name"
}
self.api = self.prompty.model.api
- self.deployment = self.prompty.model.configuration["azure_deployment"]
self.parameters = self.prompty.model.parameters
+ self.model = self.prompty.model.configuration["name"]
def invoke(self, data: any) -> any:
"""Invoke the OpenAI API
@@ -59,7 +59,7 @@ class OpenAIExecutor(Invoker):
if self.api == "chat":
trace("signature", "OpenAI.chat.completions.create")
args = {
- "model": self.deployment,
+ "model": self.model,
"messages": data if isinstance(data, list) else [data],
**self.parameters,
}
diff --git a/runtime/prompty/prompty/utils.py b/runtime/prompty/prompty/utils.py
index 2935b87..8477329 100644
--- a/runtime/prompty/prompty/utils.py
+++ b/runtime/prompty/prompty/utils.py
@@ -29,7 +29,7 @@ async def load_json_async(file_path, encoding='utf-8'):
return json.loads(content)
def _find_global_config(prompty_path: Path = Path.cwd()) -> Path:
- prompty_config = list(Path.cwd().glob("**/prompty.json"))
+ prompty_config = list(prompty_path.glob("**/prompty.json"))
if len(prompty_config) > 0:
return sorted(
|
OOF - I need to fix this! |
I'm running into a similar problem trying to use
|
I saw that error as well, it was fixed with all the changes I made to |
@injeniero thanks, going through it again and fixing it up did solve it! |
I have been debugging it and it seems to be broken. These are the issues I found:
prompty.openai
.prompty/runtime/prompty/prompty/cli.py
Line 35 in 5bbdbee
prompty/runtime/prompty/prompty/openai/executor.py
Line 25 in 5bbdbee
prompty/runtime/prompty/prompty/openai/executor.py
Line 46 in 5bbdbee
TypeError: OpenAI.__init__() got an unexpected keyword argument 'name'
The text was updated successfully, but these errors were encountered: