adri017 commited on
Commit
70e3c59
·
1 Parent(s): 04ed758

Ahora bien

Browse files
Files changed (3) hide show
  1. appGeneradorHistorias.py +26 -0
  2. appOtraUrl.py +23 -0
  3. appurl.py +23 -0
appGeneradorHistorias.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ story_generator = pipeline("text-generation", model="distilgpt2")
5
+
6
+ def generar_idea(historia_base):
7
+ resultado = story_generator(
8
+ historia_base,
9
+ max_length=150,
10
+ do_sample=True,
11
+ top_k=50,
12
+ top_p=0.95,
13
+ pad_token_id=story_generator.tokenizer.eos_token_id
14
+ )
15
+ historia = resultado[0]['generated_text']
16
+ return historia
17
+
18
+ iface = gr.Interface(
19
+ fn=generar_idea,
20
+ inputs=gr.Textbox(lines=3, placeholder="Escribe un escenario o situación base..."),
21
+ outputs=gr.Textbox(label="Historia generada"),
22
+ title="RPGHistoryMaker AI - Generador de Historias",
23
+ description="Genera pequeñas historias de RPG basadas en tu escenario o idea. Funciona sin modelos grandes ni tokens."
24
+ )
25
+
26
+ iface.launch()
appOtraUrl.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import requests
3
+
4
+ API_URL = "https://router.huggingface.co/v1/chat/completions"
5
+ headers = {
6
+ "Authorization": f"Bearer ",
7
+ }
8
+
9
+ def query(payload):
10
+ response = requests.post(API_URL, headers=headers, json=payload)
11
+ return response.json()
12
+
13
+ response = query({
14
+ "messages": [
15
+ {
16
+ "role": "user",
17
+ "content": "What is the capital of France?"
18
+ }
19
+ ],
20
+ "model": "unsloth/Qwen2.5-7B-Instruct:featherless-ai"
21
+ })
22
+
23
+ print(response["choices"][0]["message"])
appurl.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import requests
3
+
4
+ API_URL = "https://router.huggingface.co/v1/chat/completions"
5
+ headers = {
6
+ "Authorization": f"Bearer ",
7
+ }
8
+
9
+ def query(payload):
10
+ response = requests.post(API_URL, headers=headers, json=payload)
11
+ return response.json()
12
+
13
+ response = query({
14
+ "messages": [
15
+ {
16
+ "role": "user",
17
+ "content": "Tell me the name of the arcs of one piece"
18
+ }
19
+ ],
20
+ "model": "meta-llama/Llama-3.1-8B-Instruct:novita"
21
+ })
22
+
23
+ print(response["choices"][0]["message"])