Spaces:
Runtime error
Runtime error
utkuarslan5
commited on
Commit
·
ddab2a9
1
Parent(s):
5bcd928
yodafy3
Browse files
app.py
CHANGED
@@ -5,12 +5,12 @@ from langchain.chains.llm import LLMChain
|
|
5 |
from langchain.chains.constitutional_ai.base import ConstitutionalChain
|
6 |
from langchain.chains.constitutional_ai.models import ConstitutionalPrinciple
|
7 |
|
8 |
-
def yodafy(sentence):
|
9 |
|
10 |
llm = OpenAI(temperature=.8)
|
11 |
prompt = PromptTemplate(
|
12 |
-
input_variables=["sentence"],
|
13 |
-
template="
|
14 |
)
|
15 |
|
16 |
chain = LLMChain(llm=llm, prompt=prompt)
|
@@ -34,8 +34,10 @@ def yodafy(sentence):
|
|
34 |
verbose=True,
|
35 |
)
|
36 |
|
37 |
-
return constitutional_chain.run(sentence=sentence)
|
38 |
|
39 |
|
40 |
-
iface = gr.Interface(fn=yodafy,
|
|
|
|
|
41 |
iface.launch()
|
|
|
5 |
from langchain.chains.constitutional_ai.base import ConstitutionalChain
|
6 |
from langchain.chains.constitutional_ai.models import ConstitutionalPrinciple
|
7 |
|
8 |
+
def yodafy(sentence, selection):
|
9 |
|
10 |
llm = OpenAI(temperature=.8)
|
11 |
prompt = PromptTemplate(
|
12 |
+
input_variables=["sentence", "selection"],
|
13 |
+
template=f"{selection} {sentence} as Master Yoda would.",
|
14 |
)
|
15 |
|
16 |
chain = LLMChain(llm=llm, prompt=prompt)
|
|
|
34 |
verbose=True,
|
35 |
)
|
36 |
|
37 |
+
return constitutional_chain.run(sentence=sentence, selection=selection)
|
38 |
|
39 |
|
40 |
+
iface = gr.Interface(fn=yodafy,
|
41 |
+
inputs=["text", gr.inputs.Radio(["Rewrite", "Reply"])],
|
42 |
+
outputs="text")
|
43 |
iface.launch()
|