Skip to content

Instantly share code, notes, and snippets.

View Barqawiz's full-sized avatar
🚣
Working on 100 brain

cybercoder Barqawiz

🚣
Working on 100 brain
View GitHub Profile
response = openai.Answer.create(
search_model="ada",
model="curie",
question="how many planets in the solar system ?",
file="<add_file_id>",
examples_context="In 2017, U.S. life expectancy was 78.6 years.",
examples=[["What is human life expectancy in the United States?", "78 years."]],
max_tokens=5,
stop=["\n", "<|endoftext|>"])
response = openai.Answer.create(
search_model="ada",
model="curie",
question="how many planets in the solar system ?",
# question="how many years to complete orbit around galactic ?",
documents=["Our solar system is made up of a star, eight planets, and countless smaller bodies such as dwarf planets, asteroids, and comets.",
"Our solar system orbits the center of the Milky Way galaxy at about 515,000 mph (828,000 kph). We’re in one of the galaxy’s four spiral arms.",
"It takes our solar system about 230 million years to complete one orbit around the galactic center.",
"The planets of our solar system – and even some asteroids – hold more than 200 moons in their orbits.",
"There are three general kinds of galaxies: elliptical, spiral, and irregular. The Milky Way is a spiral galaxy."],
with open("solar_doc.jsonl") as f:
response = openai.File.create(
file=f,
purpose='answers')
print(response)
{"text": "Our solar system is made up of a star, eight planets, and countless smaller bodies such as dwarf planets, asteroids, and comets."}
{"text": "Our solar system orbits the center of the Milky Way galaxy at about 515,000 mph (828,000 kph). We’re in one of the galaxy’s four spiral arms."}
{"text": "It takes our solar system about 230 million years to complete one orbit around the galactic center."}
{"text": "There are three general kinds of galaxies: elliptical, spiral, and irregular. The Milky Way is a spiral galaxy."}
response = openai.Completion.create(
model="text-davinci-002",
prompt=prompt_input,
max_tokens=8,
temperature=0.1,
stop=["\n"]
)
===
Context: In 2017, U.S. life expectancy was 78.6 years.
===
Q: What is human life expectancy in the United States?
A: 78 years.
===
Context: Our solar system is made up of a star, eight planets, and countless smaller bodies such as dwarf planets, asteroids, and comets. Our solar system orbits the center of the Milky Way galaxy at about 515,000 mph (828,000 kph). We’re in one of the galaxy’s four spiral arms. It takes our solar system about 230 million years to complete one orbit around the galactic center. The planets of our solar system – and even some asteroids – hold more than 200 moons in their orbits.There are three general kinds of galaxies: elliptical, spiral, and irregular. The Milky Way is a spiral galaxy.
===
Q: how many planets in the solar system ?
A:
with open('nasa_template.txt') as f:
prompt_input = ''.join(f.readlines())
const {RemoteLanguageModel,LanguageModelInput} = require('intellinode');
const textModelInput = 'Write a creative product description for gaming chair with black and red colors';
const textProductDesc = await generateProductDescription(textModelInput, MyKeys.cohere, 'cohere', 'command');
// common function to use it with any text generation
async function generateProductDescription(textInput, apiKey, modelBackend, modelName) {
const langModel = new RemoteLanguageModel(apiKey, modelBackend);
const results = await langModel.generateText(new LanguageModelInput({
prompt: textInput,
const { Chatbot, ChatGPTInput } = require('intellinode');
const imageDescription = await getImageDescription(textProductDesc, MyKeys.openai, 'openai');
// common function to use with any future code
async function getImageDescription(textInput, apiKey, modelBackend) {
const chatbot = new Chatbot(apiKey, modelBackend);
const input = new ChatGPTInput('generate image description from paragraph to use it as prompt to generate image from DALL·E or stable diffusion image model. return only the image description to use it as direct input');
input.addUserMessage(textInput);
const responses = await chatbot.chat(input);
const {RemoteImageModel,SupportedImageModels,ImageModelInput} = require('intellinode');
const images = await generateImage(imageDescription, MyKeys.stability, SupportedImageModels.STABILITY);
// common function for future use
async function generateImage(imageText, apiKey, modelBackend) {
const imgModel = new RemoteImageModel(apiKey, modelBackend);
const imageInput = new ImageModelInput({
prompt: imageText,
numberOfImages: 3,