Skip to content

Instantly share code, notes, and snippets.

@hwchase17
Created June 29, 2023 07:19
Show Gist options
  • Save hwchase17/c7b8ea57d75bc340a23913cca8e1668f to your computer and use it in GitHub Desktop.
Save hwchase17/c7b8ea57d75bc340a23913cca8e1668f to your computer and use it in GitHub Desktop.
from langchain.chat_models import ChatOpenAI
from pydantic import BaseModel, Field
from langchain.document_loaders import UnstructuredURLLoader
from langchain.chains.openai_functions import create_extraction_chain_pydantic
class LLMItem(BaseModel):
title: str = Field(description="The simple and concise title of the product")
description: str = Field(description="The description of the product")
def main():
llm = ChatOpenAI(temperature=0, model="gpt-3.5-turbo-16k")
chain = create_extraction_chain_pydantic(pydantic_schema=LLMItem, llm=llm)
loader = UnstructuredURLLoader(urls=["https://www.ebay.com/itm/115834603826"])
data = loader.load()
llm_item = chain.run(data)
print(llm_item)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment