File size: 1,280 Bytes
495ad90
 
 
 
1fb0cfe
495ad90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e47b94
495ad90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import requests
import json
import os
from typing import List, Dict, Optional
import gradio as gr

GradientJResponse = Dict[str,str]
ChatHistory = List[Dict[str,str]]

def gradientj_api_call(
    scene:str="",
    chat_history:Optional[ChatHistory]=None
) -> GradientJResponse:
    if chat_history is None:
        chat_history = []
    
    
    url = "https://gpt.gradientj.com/api/v0/deploy/inference"
    headers = {
        "Content-Type": "application/json",
        "x-api-key": os.environ["YOUR_GJ_API_KEY"]
    }
    data = {
     "model": os.environ["model_id"],
     "params": {
      "scene": scene
     },
     "chat_history": chat_history
    }
    response = requests.post(url, headers=headers, data=json.dumps(data))
    
    if response.status_code == 200:
        return response.json()['result']
    else:
        error = response.text
        return error

demo = gr.Interface(
    fn=gradientj_api_call,
    inputs=["text"],
    outputs=["text"],
    examples=
    [[
        """SCENE 20
EXT.ROAD WARANGAL
Highway mida car velthundi
Warangal board kanipistadi
SETHUMURTHY
(Voice)
Bajji ichina information tho
mundhuki vellalem.."""
    ]],
    title="Tinglish (Telugu in Latin) to English Translation",
    description="Description ah? Bokka?")
demo.launch()