Starchik1 commited on
Commit
289ff36
·
verified ·
1 Parent(s): 145c96f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+
4
+ # Загрузка модели и токенизатора
5
+ model_name = "mistralai/Mistral-7B-Instruct-v0.3"
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ model = AutoModelForCausalLM.from_pretrained(model_name)
8
+
9
+ # Функция для анализа фьючерсов
10
+ def analyze_futures(crypto_pair):
11
+ input_text = f"Provide an analysis of the futures market for {crypto_pair}."
12
+ inputs = tokenizer(input_text, return_tensors="pt")
13
+
14
+ # Генерация ответа
15
+ with torch.no_grad():
16
+ output = model.generate(**inputs, max_length=150)
17
+
18
+ response = tokenizer.decode(output[0], skip_special_tokens=True)
19
+ return response
20
+
21
+ # Создание интерфейса с помощью Gradio
22
+ interface = gr.Interface(
23
+ fn=analyze_futures,
24
+ inputs=gr.Textbox(label="Crypto Pair", placeholder="Enter crypto pair (e.g., BNBUSDT, BTCUSDT)"),
25
+ outputs="text",
26
+ title="Futures Market Analysis",
27
+ description="Enter a crypto pair to get an analysis of its futures market."
28
+ )
29
+
30
+ # Запуск интерфейса
31
+ interface.launch()