-
Notifications
You must be signed in to change notification settings - Fork 29
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
How do we insert variables into tool docstring? #271
Comments
To achieve similar functionality in Mirascope, where you want to inject the schema of a PostgreSQL table into your docstring so that the model can interpret the list of values being returned from the function correctly, you would follow a process similar to what you described but tailored to Mirascope's capabilities and syntax. Since Mirascope doesn't have a direct equivalent to the OpenAI cookbook guide's method of embedding dynamic content within docstrings, you'll need to manually construct your docstring to include the necessary details about the database schema. Here's a step-by-step approach to accomplish this:
Here's an example of how you might define such a function in Mirascope, assuming you've retrieved and converted your PostgreSQL table schema into a string named def get_user_data(user_id):
"""
Retrieve detailed information about a user based on their ID.
:param user_id: The ID of the user to retrieve information for.
:return: A dictionary containing the user's information, including fields like name, email, and registration date.
Note: The following schema describes the structure of the data returned by this function:
{postgres_table_schema}
Example return value:
{
"id": 123,
"name": "John Doe",
"email": "[email protected]",
"registration_date": "2024-01-01"
}
"""
# Function implementation here In this example, Remember, the key to successfully injecting schema information into your docstring lies in accurately representing the schema in a readable format and ensuring that the schema string is correctly embedded into the docstring. This approach requires manual intervention but allows for precise control over the information presented to the model and users of your function. |
@ashishpatel26 Manual injection is OK but it's not ideal solution in my case. The database schema could be updated frequently. It's going to be cumbersome to have to update the docstring every time your schema changes. Also if possible, please instruct your ChatGPT to be a bit more concise. If all it's going to say is to inject data manually, it could do that in 3 sentences max. Appreciate your help though. |
@off6atomic this is really interesting. I've thought a little bit about this:
In the meantime, you can also always just insert the dynamic string into the Thanks for bringing this up! |
Question
This is how we insert arbitrary variables into tool description from the official OpenAI cookbook guide:
Notice that we are inserting the database schema into the function specification. This will be important for the model to know about.
How can we achieve same behavior in Mirascope?
Goal
I'm trying to inject schema of a Postgres table into my docstring so that the model can interpret list of values being returned from the function correctly.
The text was updated successfully, but these errors were encountered: