Spaces:
Build error
Build error
Upload 2 files
Browse filesFiles changed (2)
- app.py+21-20
- requirements.txt+2-1
12345678 unmodified lines16171819202122232425262728293031323334353637383940414243444546474849import gradio as grimport requestsimport coheredef get_weather_data():lat = 27.02388 unmodified linesdef generate_prompt(data):weather_json = get_weather_data()prompt = \f'''Category: {data["Category"]}Crop Type: {data["Crop"]}Query Type: {data["QueryType"]}State: {data["StateName"].lower()}District: {data["DistrictName"].lower()}Max Temprature: {weather_json["temp_max"]}Min Temprature: {weather_json["temp_min"]}Humidity: {weather_json["humidity"]}Weather Description: {weather_json["description"]}Question: {data["QueryTranslated"]}'''return promptdef get_response(prompt):co = cohere.Client('EoYqxEa60C0EEeKadblGW8NE94geVCEE75lDqySe')response = co.generate(model='command-xlarge-nightly',prompt = prompt,max_tokens=40,temperature=0.6,stop_sequences=["--"])print(response[0])return response.generations[0].textoutputs = gr.outputs.Textbox()iface = gr.Interface(fn=get_response,inputs=[gr.Textbox(label = 'First Code snippet')],outputs=[gr.Textbox(label = 'Summary of first Code snippet')],description='The similarity score')iface.launch()12345678 unmodified lines1617181920212223242526272829303132333435363738394041424344454647484950import gradio as grimport requestsimport coherefrom translate import Translatordef get_weather_data():lat = 27.02388 unmodified linesdef generate_prompt(data):weather_json = get_weather_data()prompt = \f'''State: RajasthanMax Temprature: {weather_json["temp_max"]}Min Temprature: {weather_json["temp_min"]}Humidity: {weather_json["humidity"]}Weather Description: {weather_json["description"]}Context: Through increased use of soil testing and plant analyses, micronutrient deficiencies have been verified in many soils. Some reasons limiting the incidental additions of micronutrients include.High-yield crop demands remove micronutrients from the soil. Increased use of high-analysis NPK fertilizers containing lower quantities of micronutrient contaminants. Advances in fertilizer technology reduce the residual addition of micronutrients.Question: {data}'''return promptdef get_response(prompt):co = cohere.Client('EoYqxEa60C0EEeKadblGW8NE94geVCEE75lDqySe')new_prompt = generate_prompt(prompt)response = co.generate(model='command-xlarge-nightly',prompt = new_prompt,max_tokens = 1000,temperature = 0.6,stop_sequences = ["--"])translator = Translator(to_lang="hi")translation = translator.translate(response.generations[0].text)return translationtitle = """<h1 align="center">🌱 Farmer Queries LLM | किसान प्रश्न LLM 🌾</h1>"""with gr.Blocks(css="""#col_container {margin-left: auto; margin-right: auto;} #chatbot {height: 520px; overflow: auto;}""") as demo:gr.HTML(title)input1 = gr.Textbox(label = 'प्रश्न पूछो')output1 = gr.Textbox(label = 'उत्तर')btn = gr.Button("जमा करे")btn.click(get_response, [input1], output1)demo.launch()
1cohere12coheretranslate
app.py+21-20
requirements.txt+2-1