Hello everyone,In this post I'm gonna show you can build one of the most amazing application out of GPT-3.
A tool which can explain you code so you can roam freely in an unknown territory.
It will be able to explain you code in any major programming language like C,C++,Java,Python, Javascript, Assembly,Golang etc.
So without wasting any time let's start with the coding part.
Part-1:Connecting the API
pip install openai
import os
import openai
openai.api_key = input("API-KEY:")
def result(code):
response = openai.Completion.create(
engine="text-davinci-002",
prompt="Explain this code line by line "+code,
temperature=0.7,
max_tokens=100,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
return response['choices'][0]['text']
Part-2:Building Gradio Interface
pip install gradio
import gradio as gr
demo = gr.Interface(
fn=result,
inputs=gr.Textbox(lines=10),
outputs="text",
)
demo.launch(debug=True)
Here's the link to the Colab Notebook:
Top comments (0)