mirror of
https://github.com/kennethreitz/instructor.git
synced 2026-06-05 22:50:18 +00:00
Implement DSL and documentation
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
from openai_function_call import OpenAISchema, dsl
|
||||
from pydantic import Field
|
||||
|
||||
|
||||
class SearchQuery(OpenAISchema):
|
||||
query: str = Field(
|
||||
...,
|
||||
description="Detailed, comprehensive, and specific query to be used for semantic search",
|
||||
)
|
||||
|
||||
|
||||
SearchResponse = dsl.MultiTask(
|
||||
subtask_class=SearchQuery,
|
||||
description="Correctly segmented set of search queries",
|
||||
)
|
||||
|
||||
|
||||
task = (
|
||||
dsl.ChatCompletion(name="Segmenting Search requests example")
|
||||
| dsl.SystemTask(task="Segment search results")
|
||||
| dsl.TaggedMessage(
|
||||
content="can you send me the data about the video investment and the one about spot the dog?",
|
||||
tag="query",
|
||||
)
|
||||
| dsl.TipsMessage(
|
||||
tips=[
|
||||
"Expand query to contain multiple forms of the same word (SSO -> Single Sign On)",
|
||||
"Use the title to explain what the query should return, but use the query to complete the search",
|
||||
"The query should be detailed, specific, and cast a wide net when possible",
|
||||
]
|
||||
)
|
||||
| SearchResponse
|
||||
)
|
||||
import pprint
|
||||
|
||||
import json
|
||||
|
||||
print(json.dumps(task.kwargs, indent=1))
|
||||
"""
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"query": "data about video investment"
|
||||
},
|
||||
{
|
||||
"query": "data about spot the dog"
|
||||
}
|
||||
]
|
||||
}
|
||||
"""
|
||||
Reference in New Issue
Block a user