Spaces:
Running
Running
| _O='Augmented Prompt' | |
| _N='Multi-Modal Prompt' | |
| _M='Code Prompt' | |
| _L='React Prompt' | |
| _K='Chain-of-thought Prompt' | |
| _J='Step-back Prompt' | |
| _I='Role Prompt' | |
| _H='Contextual Prompt' | |
| _G='System Prompt' | |
| _F='Few Shot Prompt' | |
| _E='One Shot Prompt' | |
| _D='Zero Shot Prompt' | |
| _C='API_KEY' | |
| _B='content' | |
| _A='role' | |
| import os | |
| from openai import OpenAI | |
| import gradio as gr | |
| API_KEY=os.environ[_C] | |
| messages=[{_A:'system',_B:'You are AI specialized in Prompt Engineering'}] | |
| client=OpenAI(base_url='https://openrouter.ai/api/v1',api_key=_C,default_headers={'Authorization':f"Bearer {API_KEY}",'HTTP-Referer':'','X-Title':''}) | |
| def chatbot(input,prompt_type): | |
| A=prompt_type | |
| if input: | |
| if A==_D:input+='' | |
| elif A==_E:input+=' Convert this zero shot prompt to one shot prompt' | |
| elif A==_F:input+=' Convert this zero shot prompt to few shot prompt' | |
| elif A==_G:input+=' Convert this zero shot prompt to system prompt' | |
| elif A==_H:input+=' Convert this zero shot prompt to contextual prompt' | |
| elif A==_I:input+=' Convert this zero shot prompt to role prompt' | |
| elif A==_J:input+=' Convert this zero shot prompt to step-back prompt' | |
| elif A==_K:input+=' Convert this zero shot prompt to chain-of-thought prompt' | |
| elif A=='Tree-of-thought':input+=' Convert this zero shot prompt to tree-of-thought prompt' | |
| elif A==_L:input+=' Convert this zero shot prompt to react prompt' | |
| elif A==_M:input+=' Convert this zero shot prompt to code prompt' | |
| elif A==_N:input+=' Convert this zero shot prompt to multi-Modal prompt' | |
| elif A==_O:input+=' Convert this zero shot prompt to augmented prompt' | |
| messages.append({_A:'user',_B:f"{A}: {input}"});C=client.chat.completions.create(model='deepseek/deepseek-r1:free',messages=messages);B=C.choices[0].message.content;messages.append({_A:'assistant',_B:B});return B | |
| prompt_types=[_D,_E,_F,_G,_H,_I,_J,_K,'Tree-of-thought Prompt',_L,_M,_N,_O] | |
| with gr.Blocks(theme=gr.themes.Default(primary_hue='sky'))as promptengineering:dropdown=gr.Dropdown(choices=prompt_types,label='Select Prompt Type:',type='value');inputs=gr.Textbox(lines=7,label='',placeholder='Prompt : Try - What is the value of pi');outputs=gr.Textbox(label='Response:');gr.Interface(fn=chatbot,inputs=[dropdown,inputs],outputs=outputs) | |
| promptengineering.launch(share=True) |