Skip to content

Commit

Permalink
add groq example for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Jun 15, 2024
1 parent 06741bf commit 38dcee4
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions examples/models/groq_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from funcchain import chain, settings
from langchain_groq import ChatGroq
from pydantic import BaseModel, Field
from rich import print


class SentimentAnalysis(BaseModel):
analysis: str = Field(description="A description of the analysis")
sentiment: bool = Field(description="True for Happy, False for Sad")


def analyze(text: str) -> SentimentAnalysis:
"""
Determines the sentiment of the text.
"""
return chain()


if __name__ == "__main__":
# set global llm
settings.llm = ChatGroq(model="llama3-70b-8192")
# log tokens as stream to console
settings.console_stream = True

# run prompt
result = analyze("I really like when my dog does a trick!")

# show final parsed output
print(result)

0 comments on commit 38dcee4

Please sign in to comment.