File size: 2,609 Bytes
2694503
b65b755
2694503
80c53a2
9f1e952
f70d981
2694503
c532af7
5d8c89a
 
 
 
ce2abbe
 
 
2ac511b
43c14e0
 
b65b755
 
 
 
 
2ac511b
9bfebe1
b65b755
 
 
 
 
 
 
 
 
 
2ac511b
b65b755
 
2ac511b
b65b755
2ac511b
b65b755
1c96088
 
 
 
 
 
b65b755
 
 
 
 
ce2abbe
 
2694503
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import os
import gradio as gr
from groq import Groq
from dotenv import load_dotenv
import json
load_dotenv()

api1 = os.getenv("GROQ_API_KEY")

apis = [
    api1,
    # api1,
]


def make_call(data):
    print(data)
    answer = None
    while True:
        for api in apis:
            client = Groq(
                    api_key=api,
                )  # Configure the model with the API key
            # query = st.text_input("Enter your query")
            prmptquery= f"Answer this query as a friend with wisdom, love and compassion, in context to bhagwat geeta, provide references of shloks from chapters of bhagwat geeta which is relevant to the query. Query= {data}"
            try:
                response = client.chat.completions.create(
                messages=[
                    {
                        "role": "user",
                        "content": prmptquery,
                    }
                ],
                model="mixtral-8x7b-32768",
                )
                answer = response.choices[0].message.content
            except Exception as e:
                print(f"API call failed for: {e}")
            if answer:
                break
        if answer:
                break
    respo = {
                "message": answer,
                "action": "nothing",
                "function": "nothing",
            }
    return json.dumps(respo)



gradio_interface = gr.Interface(fn=make_call, inputs="text", outputs="text")
gradio_interface.launch()

# print(chat_completion)

























# # Text to 3D

# import streamlit as st
# import torch
# from diffusers import ShapEPipeline
# from diffusers.utils import export_to_gif

# # Model loading (Ideally done once at the start for efficiency)
# ckpt_id = "openai/shap-e"  
# @st.cache_resource  # Caches the model for faster subsequent runs
# def load_model():
#     return ShapEPipeline.from_pretrained(ckpt_id).to("cuda")  

# pipe = load_model()

# # App Title
# st.title("Shark 3D Image Generator")

# # User Inputs
# prompt = st.text_input("Enter your prompt:", "a shark")
# guidance_scale = st.slider("Guidance Scale", 0.0, 20.0, 15.0, step=0.5)

# # Generate and Display Images
# if st.button("Generate"):
#     with st.spinner("Generating images..."):
#         images = pipe(
#             prompt,
#             guidance_scale=guidance_scale,
#             num_inference_steps=64,
#             size=256,
#         ).images
#         gif_path = export_to_gif(images, "shark_3d.gif")

#         st.image(images[0])  # Display the first image
#         st.success("GIF saved as shark_3d.gif")