Chainlit / literalai-python

https://docs.getliteral.ai/
Apache License 2.0
12 stars 0 forks source link

fix: add token usage #121

Closed desaxce closed 1 month ago

desaxce commented 1 month ago

Changes:

To test:

from langchain_anthropic import ChatAnthropic from langchain.schema.runnable.config import RunnableConfig from langchain.schema import StrOutputParser from langchain.prompts import ChatPromptTemplate

Set ANTHROPIC_API_KEY

literal_client = LiteralClient(api_key="lsk-***")

cb = literal_client.langchain_callback()

prompt = ChatPromptTemplate.from_messages( ['human', 'Tell me a short joke about {topic}'] )

model = ChatAnthropic(model_name="claude-3-5-sonnet-20240620") runnable = prompt | model

res = runnable.invoke( {"topic": "ice cream"}, config=RunnableConfig(callbacks=[cb], run_name="joke") )

desaxce commented 1 month ago

It works with ChatAnthropic(model_name="claude-3-5-sonnet-20240620", streaming=True) too.

kumar781 commented 1 month ago

will it work with azureopenai gpt 4o?