benman1 / generative_ai_with_langchain

Build large language model (LLM) apps with Python, ChatGPT and other models. This is the companion repository for the book on generative AI with LangChain.
https://amzn.to/43PuIkQ
MIT License
552 stars 219 forks source link

No citation for summarize code in Chapter 4 #10

Closed andysingal closed 6 months ago

andysingal commented 7 months ago

Hey Ben, Thanks for this amazing book, Checking to see if you can share citation for the code:

with get_openai_callback() as cb:
    response = llm_chain.predict(text=”Complete this text!”)
    print(f"Total Tokens: {cb.total_tokens}")
    print(f"Prompt Tokens: {cb.prompt_tokens}")
    print(f"Completion Tokens: {cb.completion_tokens}")
    print(f"Total Cost (USD): ${cb.total_cost}")
from langchain.chains import LLMCheckerChain
from langchain.llms import OpenAI
llm = OpenAI(temperature=0.7)
text = "What type of mammal lays the biggest eggs?"
checker_chain = LLMCheckerChain.from_llm(llm, verbose=True)
checker_chain.run(text)
benman1 commented 6 months ago

Hi @andysingal! This is from chapter 4. Does this answer your question?

benman1 commented 6 months ago

@andysingal does this answer your question?

andysingal commented 6 months ago

Hi @andysingal! This is from chapter 4. Does this answer your question?

Can you please point out in your book, it makes life much easier. Thank you

benman1 commented 6 months ago

In the pdf version it's page 110. Hope this helps. I am closing this now.