File size: 1,572 Bytes
853b568
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14698eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import requests

API_URL = "https://api-inference.huggingface.co/models/TaylorAI/gte-tiny"
headers = {"Authorization": "Bearer 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"}

def query(payload):
    response = requests.post(API_URL, headers=headers, json=payload)
    return response.json()

st.title("GTE Chat App")

# Create a text input for the user to enter their message
message = st.text_input("Enter your message:")

# Create a button to trigger the chatbot response
button = st.button("Send")

# When the button is clicked, call the query function with the user's message as the payload
if button:
    output = query({
        "inputs": {
            "source_sentence": message,
            "sentences": [
                "That is a happy dog",
                "That is a very happy person",
                "Today is a sunny day"
            ]
        },
    })

    # Print the chatbot's response
    st.write(output)

    # Create a text input for the chatbot's response
    chatbot_response = st.text_input("Chatbot's response:")

    # When the user enters a response, call the query function again with the user's response as the payload
    if chatbot_response:
        output = query({
            "inputs": {
                "source_sentence": chatbot_response,
                "sentences": [
                    "That is a happy dog",
                    "That is a very happy person",
                    "Today is a sunny day"
                ]
            },
        })

        # Print the chatbot's response
        st.write(output)