-
Notifications
You must be signed in to change notification settings - Fork 1.5k
chore(wren-ai-service): Using OpenAI API Structured Output #731
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
Conversation
cyyeh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MGomaa435
Thanks for your contributions! I've left some comments. I'll also spend some other time to try the changes using openai llms!
| api_base: str = os.getenv("LLM_OPENAI_API_BASE") or LLM_OPENAI_API_BASE, | ||
| model: str = os.getenv("GENERATION_MODEL") or GENERATION_MODEL, | ||
| kwargs: Dict[str, Any] = ( | ||
| kwargs: set[Dict[str, Any]] = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excuse me, could you explain to me why this should be set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not needed; it will be reverted to the original Dict.
| results: list[SQLResult] | ||
|
|
||
|
|
||
| Generation_MODEL_KWARGS = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this constant be capitalized? please change all xxx_MODEL_KWARGS to all capitalized. thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, will be updated.
| message = ChatMessage.from_user(prompt) | ||
| if self.system_prompt: | ||
| messages = [ChatMessage.from_system(self.system_prompt), message] | ||
| # updated from_system to from_assistent as the new openai api is not accepting system prompts anymore, only user and assistant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the info, could you also provide relevant release note or sth I can look further?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://community.openai.com/t/o1-models-do-not-support-system-role-in-chat-completion/953880/2
This is for o1 models and they would change it for all.
# Conflicts: # wren-ai-service/src/pipelines/retrieval/retrieval.py
|
reopen |
cyyeh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all xxx_MODEL_KWARGS should be capitalized, thank you
| relationships: list[ModelRelationship] | ||
|
|
||
|
|
||
| Relationship_MODEL_KWARGS = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you also make this capitalized? thanks! @MGomaa435
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| return AsyncGenerator( | ||
| model=self._generation_model, | ||
| url=f"{self._url}/api/generate", | ||
| url=f"{self._url}/apx i/generate", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| model=self._generation_model, | ||
| url=f"{self._url}/api/generate", | ||
| url=f"{self._url}/apx i/generate", | ||
| generation_kwargs=self._model_kwargs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be {**generation_kwargs, **self._model_kwargs}?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also please change it in azure_openai.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…tic model. -- following naming convention
cyyeh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for your contribution!
we are adapting the new OpenAI API structured output format using the Pydantic model.