-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #322 from parea-ai/add-cookbook-example-lc
add cookbook example, loadenv in client
- Loading branch information
Showing
3 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import os | ||
|
||
from dotenv import load_dotenv | ||
from langchain_community.chat_models import ChatOpenAI | ||
from langchain_core.output_parsers import StrOutputParser | ||
from langchain_core.prompts import ChatPromptTemplate | ||
|
||
from parea import Parea | ||
from parea.utils.trace_integrations.langchain import PareaAILangchainTracer | ||
|
||
load_dotenv() | ||
|
||
p = Parea(api_key=os.getenv("PAREA_API_KEY")) | ||
handler = PareaAILangchainTracer() | ||
|
||
llm = ChatOpenAI(openai_api_key=os.getenv("OPENAI_API_KEY")) | ||
prompt = ChatPromptTemplate.from_messages([("user", "{input}")]) | ||
chain = prompt | llm | StrOutputParser() | ||
|
||
|
||
def main(): | ||
return chain.invoke( | ||
{"input": "Write a Hello World program in Python using FastAPI."}, | ||
config={"callbacks": [handler]}, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
print(main()) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ build-backend = "poetry.core.masonry.api" | |
[tool.poetry] | ||
name = "parea-ai" | ||
packages = [{ include = "parea" }] | ||
version = "0.2.29" | ||
version = "0.2.30a0" | ||
description = "Parea python sdk" | ||
readme = "README.md" | ||
authors = ["joel-parea-ai <[email protected]>"] | ||
|