-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from polyfact/feat/prompt
✨ Add prompt management
- Loading branch information
Showing
12 changed files
with
249 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { generate, getAllPrompts } from "../lib/index"; | ||
|
||
const systemPrompt = `Add all numbers together which are given in an array. your response have to be like : "4" or "2"`; | ||
|
||
(async () => { | ||
const res = await generate("[7, 8, 9]", { | ||
systemPrompt, | ||
infos: true, | ||
}); | ||
console.log(res); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import client, { PromptInsert, Filter } from "../lib/prompt"; | ||
|
||
async function main() { | ||
const apiClient = client({ | ||
token: "YOUR_API_TOKEN", | ||
endpoint: "https://localhost:8080", | ||
}); | ||
|
||
// Create a new prompt | ||
const newPrompt: PromptInsert = { | ||
name: "Test Prompt", | ||
description: "This is a test prompt description.", | ||
prompt: "What is the meaning of life?", | ||
tags: ["philosophy", "life"], | ||
}; | ||
const createdPrompt = await apiClient.createPrompt(newPrompt); | ||
console.log("Created Prompt:", createdPrompt); | ||
|
||
// Get all prompts | ||
const allPrompts = await apiClient.getAllPrompts(); | ||
console.log("All Prompts:", allPrompts); | ||
|
||
// Get all prompts filtered by name | ||
const filterByName: Filter = { | ||
column: "name", | ||
operation: "eq", | ||
value: "Test Prompt", | ||
}; | ||
const filteredPrompts = await apiClient.getAllPrompts([filterByName]); | ||
console.log("Filtered Prompts:", filteredPrompts); | ||
|
||
// Update a prompt | ||
const updatedData = { description: "Updated description" }; | ||
const updatedPrompt = await apiClient.updatePrompt(createdPrompt.id, updatedData); | ||
console.log("Updated Prompt:", updatedPrompt); | ||
|
||
// Delete a prompt | ||
await apiClient.deletePrompt(createdPrompt.id); | ||
console.log("Prompt Deleted!"); | ||
} | ||
|
||
main().catch((error) => { | ||
console.error("An error occurred:", error); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { generate } from "../lib/index"; | ||
|
||
(async () => { | ||
const res = await generate( | ||
"i want a Swiss white beger dog", | ||
{ | ||
promptId: "f4a1f732-9c38-4bdb-b9e4-3baa7971286a", | ||
infos: true, | ||
}, | ||
{ | ||
endpoint: "http://localhost:8080", | ||
token: "<token>", | ||
}, | ||
); | ||
console.log(res); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.