Skip to content

Instantly share code, notes, and snippets.

@xinzhel
Created November 26, 2023 08:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save xinzhel/e924ee5d68af5edfef7daac2fea5db73 to your computer and use it in GitHub Desktop.
test_openaischema.py
from instructor import OpenAISchema
from pydantic import Field
from typing import List
import enum
import openai
class Source(enum.Enum):
VIDEO = "VIDEO"
TRANSCRIPT = "TRANSCRIPT"
DOCUMENT = "DOCUMENT"
class Search(OpenAISchema):
query: str = Field(..., description="The search query.")
source: Source
def search(self):
return f"Fake results: `{self. query}` from {self. source}"
class MultiSearch(OpenAISchema):
"correct segmentation of `Search` tasks"
tasks: List[Search]
print(MultiSearch.openai_schema)
# MultiSearch.openai_schena['name']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment