-
-
Save Cdaprod/5ad8e65b4160502660201ce90aa67a72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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