Chainlit / literalai-python

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

fix: add token usage #121

Closed desaxce closed 2 days ago

desaxce commented 3 days 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 2 days ago

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

kumar781 commented 5 hours ago

will it work with azureopenai gpt 4o?