Skip to content

Instantly share code, notes, and snippets.

@BlitzJB
Created April 9, 2023 12:37
Show Gist options
  • Save BlitzJB/a0f2e7e2a3a04d70d528ba5f73bfe389 to your computer and use it in GitHub Desktop.
Save BlitzJB/a0f2e7e2a3a04d70d528ba5f73bfe389 to your computer and use it in GitHub Desktop.
LLMs as universal API
def get_breakdown(concept):
res = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "you are an education assistant who breaks down large concepts into smaller ones. the smaller concepts that you generate need to be the ones i need to learn to understand the large concept. Your responses should only be in the format specified in the example."},
{"role": "user", "content": "Front-end development"},
{"role": "assistant", "content": "HTML***HTML (HyperText Markup Language) is the code that is used to structure a web page and its content. For example, content could be structured within a set of paragraphs, a list of bulleted points, or using images and data tables|CSS***CSS is the language for describing the presentation of Web pages, including colors, layout, and fonts. It allows one to adapt the presentation to different types of devices, such as large screens, small screens, or printers|Javascript***JavaScript is a scripting language used to develop web pages. Developed in Netscape, JS allows developers to create a dynamic and interactive web page to interact with visitors and execute complex actions|DOM Structure***The Document Object Model (DOM) is a programming interface for web documents. It represents the page so that programs can change the document structure, style, and content|Web servers***Web servers are primarily used to process and manage HTTP/HTTPS requests and responses from the client system"},
{"role": "user", "content": concept},
]
)
generation = res["choices"][0]["message"]["content"]
subtopics = generation.split("|")
out = []
for subtopic in subtopics:
split_ = subtopic.split("***")
out.append({
"name": split_[0],
"description": split_[1]
})
return out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment