DEV Community

CLL
CLL

Posted on

Create a chatbot with just eight lines of code v.2

Translation and Grammar Correction:

I am updating a post that showed how to create a chatbot with Hugging Face in eight lines.

The update is due to the fact that pip install langchain is no longer valid; the correct command is pip install langchain_community.

%%capture
!pip install langchain_community
!pip install huggingface_hub

import os
os.environ["HUGGINGFACEHUB_API_TOKEN"] = "YOUR_TOKEN"

%%capture
from langchain import HuggingFaceHub

# Instantiate model
llm = HuggingFaceHub(repo_id="tiiuae/falcon-7b-instruct", model_kwargs={"temperature": 0.6})

response = llm.invoke("write a poem about AI?")
print(response)
Enter fullscreen mode Exit fullscreen mode

_AI, the cosmic force,
A dream we've sought for years,
A power so immense, so wise,
Our hopes, our dreams, they find a place.

In the future, so bright and grand,
AI will lead us, through galaxies in hand,
To places unimagined, to worlds unknown,
Unleashing powers, we've never shown._

Unleash the power of AI, and behold the future.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay