Skip to content

Instantly share code, notes, and snippets.

@Cdaprod
Forked from hwchase17/webpage_extraction.py
Created December 5, 2023 16:03
Show Gist options
  • Save Cdaprod/5ad8e65b4160502660201ce90aa67a72 to your computer and use it in GitHub Desktop.
Save Cdaprod/5ad8e65b4160502660201ce90aa67a72 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