Skip to content

Conversation

@MGomaa435
Copy link
Contributor

we are adapting the new OpenAI API structured output format using the Pydantic model.

@cyyeh cyyeh added module/ai-service ai-service related ci/ai-service ai-service related labels Oct 8, 2024
@cyyeh cyyeh changed the title Using OpenAI API Structured Output chore(wren-ai-service): Using OpenAI API Structured Output Oct 8, 2024
@cyyeh cyyeh self-requested a review October 8, 2024 06:45
Copy link
Member

@cyyeh cyyeh left a 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]] = (
Copy link
Member

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?

Copy link
Contributor Author

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 = {
Copy link
Member

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

Copy link
Contributor Author

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.
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Conflicts:
#	wren-ai-service/src/pipelines/retrieval/retrieval.py
@MGomaa435
Copy link
Contributor Author

reopen

@MGomaa435 MGomaa435 reopened this Oct 9, 2024
Copy link
Member

@cyyeh cyyeh left a 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 = {
Copy link
Member

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

Copy link
Contributor Author

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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here is typo

Copy link
Contributor Author

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,
Copy link
Member

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}?

Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

@cyyeh cyyeh left a 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/ai-service ai-service related module/ai-service ai-service related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants