File size: 1,069 Bytes
2d0e180
7e3533c
50cb668
2d0e180
50cb668
2d0e180
7e3533c
 
 
 
 
 
 
 
 
 
 
 
 
5014c6f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7e3533c
 
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
37
38
39
40
41
import gradio as gr
from langchain.chat_models import init_chat_model
import os

key = os.getenv("groqdummy")


def groq_endpoint(message, history):
    # Create a ChatGroq LLM on-the-fly, or reuse a global one.

    model = init_chat_model("llama3-8b-8192", model_provider="groq",api_key=key)
    result = model.invoke(message)


    return str (result.content)


# demo = gr.ChatInterface(fn=groq_endpoint, type="messages", examples=["hello","merhaba"], title="DS-10_Chatbot")
# demo.launch(debug=True)

css = """
label[data-testid="block-label"] {
    display: none !important;
}
footer {
    display: none !important;
}
"""

js_func = """
function refresh() {
    const url = new URL(window.location);
    if (url.searchParams.get('__theme') !== 'dark') {
        url.searchParams.set('__theme', 'dark');
        window.location.href = url.href;
    }
}
"""
with gr.Blocks(css=css, js = js_func, theme="monochrome") as demo:
  chatbot = gr.ChatInterface(fn=groq_endpoint, type="messages", examples=["hello","merhaba"], title="DS-10_Chatbot")
demo.launch(debug=True)