An Interest In:
Web News this Week
- March 19, 2024
- March 18, 2024
- March 17, 2024
- March 16, 2024
- March 15, 2024
- March 14, 2024
- March 13, 2024
July 13, 2022 08:39 am GMT
Original Link: https://dev.to/thisisanshgupta/explaining-code-with-gpt-3-4233
Explaining Code with GPT-3
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 osimport openaiopenai.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 grdemo = gr.Interface( fn=result, inputs=gr.Textbox(lines=10), outputs="text", )demo.launch(debug=True)
Here's the link to the Colab Notebook:
Original Link: https://dev.to/thisisanshgupta/explaining-code-with-gpt-3-4233
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To