File size: 844 Bytes
048465c
 
70d7f29
0f08bd3
048465c
70d7f29
d0f318a
70d7f29
d0f318a
 
 
 
 
 
048465c
 
aafb916
048465c
 
 
70d7f29
048465c
aafb916
 
70d7f29
048465c
70d7f29
048465c
 
 
 
 
aafb916
70d7f29
 
048465c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from langchain_ollama import ChatOllama
from langchain_core.prompts import ChatPromptTemplate
import gradio as gr
from langchain_groq import ChatGroq
import os

groq_api_key = os.environ.get("GROQ_API_KEY")

llm = ChatGroq(
    model="mixtral-8x7b-32768",  
    temperature=0.7,
    api_key=groq_api_key,
    verbose = False
)
prompt = ChatPromptTemplate.from_messages(
    [
        ("system","Generate a list of synonyms for the following word, only give 5 words with examples."),
        ("human","{input}")
    ]
)

def synonyms(text):
    response = chain.invoke({"input": text})
    return response.content 

chain = prompt | llm

demo = gr.Interface(
    fn = synonyms,
    inputs = ["text"],
    outputs = ["text"],
    title = "Synonym Generator",
    description = "Generate a list of synonyms for the following word"
)

demo.launch()