Skip to content

Commit 752a921

Browse files
docs: updated links for no real docs
1 parent 138f1f1 commit 752a921

File tree

1 file changed

+181
-28
lines changed

1 file changed

+181
-28
lines changed

README.md

Lines changed: 181 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<h1 align="center">🔥 polyfire</h1>
22

33
<h4 align="center">
4-
<a href="https://docs.polyfire.com">Documentation</a> |
54
<a href="https://www.polyfire.com/discord">Discord</a> | <a href="https://beta.polyfire.com">Dashboard</a>
65
</h4>
76

@@ -17,10 +16,6 @@ We **manage your AI backend** so you don't have to.
1716

1817
![Demo Gif](https://files.readme.io/7442014-demo.gif)
1918

20-
## 🧰 Examples
21-
22-
We have several examples in our [documentation](https://docs.polyfire.com/). But here are two simple ones to get you started
23-
2419
### React
2520

2621
```js
@@ -69,35 +64,193 @@ root.render(
6964

7065
> Don't forget to change the **your_project_id** by your project ID you will have got on https://beta.polyfire.com
7166
72-
## 🆕 Getting Started
67+
## 🔗 Links
7368
74-
To get an overview of Polyfire follow this **[Basic Usage](https://docs.polyfire.com/docs/basic-usage)** tutorial.
69+
- Website: [polyfire.com](https://www.polyfire.com)
70+
- Dashboard: [beta.polyfire.com](https://beta.polyfire.com)
71+
- Discord: [polyfire.com/discord](https://www.polyfire.com/discord)
72+
- Javascript SDK: [github.com/polyfact/polyfire-js](https://www.github.com/polyfact/polyfire-js)
73+
- Open Source API (your managed backend!): [github.com/polyfact/polyfire-api](https://github.com/polyfact/polyfire-api)
7574
76-
## ✨ Starter Guides
75+
We're open source! Make a good PR to the JS SDK or the API and we'll merge it.
7776
78-
We also made a couple of tutorials you can use to get started with Polyfire:
7977
80-
- **[How to make a clone of ChatGPT](https://docs.polyfire.com/docs/chatgpt-clone)**
81-
- **[New Project & Rate Limits](https://docs.polyfire.com/docs/new-project-rate-limit)**
82-
- **[Adding stripe subscriptions](https://docs.polyfire.com/docs/react-stripe-subscriptions)**
83-
- **[Call Polyfire from React](https://docs.polyfire.com/docs/usepolyfire)**: The usePolyfire hooks lets you use Polyfire and handle authentification without having to deploy any backend
84-
- **[Call Polyfire from other browser environments](https://docs.polyfire.com/docs/javascript)**: The Polyfire Client Object allows you to use Polyfire and handle authentification without having to deploy any backend in any environment
78+
# SDK Documentation
8579
86-
## 📚 Useful References
80+
## Overview
8781
88-
- **[Generate Simple Text](https://docs.polyfire.com/reference/generate)**: Answer to simple requests as text
89-
- **[Create Chatbots](https://docs.polyfire.com/reference/chats)**: Easily create chatbots
90-
- **[Transcribe](https://docs.polyfire.com/reference/transcribe)**: Transcribe audio files to text
91-
- **[Memory](https://docs.polyfire.com/reference/embeddings)**: Easily create a long-term memory and simplify the use of large amounts of information
92-
- **[GenerateImage](https://docs.polyfire.com/reference/generate-image)**: Generate images with Dall-E
82+
This SDK provides functionalities for text generation, transcription, memory management, image generation, and data loading. Below is a guide on how to use these features.
9383
94-
## 🔗 Links
84+
### Installation
9585
96-
- Website: [polyfire.com](https://www.polyfire.com)
97-
- Documentation: [docs.polyfire.com](https://docs.polyfire.com)
98-
- Dashboard: [beta.polyfire.com](https://beta.polyfire.com)
99-
- Discord: [polyfire.com/discord](https://www.polyfire.com/discord)
100-
- Javascript SDK: [github.com/polyfire-ai/polyfire-js](https://www.github.com/polyfire-ai/polyfire-js)
101-
- Open Source API (your managed backend!): [github.com/polyfire-ai/polyfire-api](https://github.com/polyfire-ai/polyfire-api)
86+
To install the SDK, use the following command:
87+
88+
```bash
89+
npm install polyfire-js
90+
```
91+
92+
### Importing the SDK
93+
94+
To use the SDK, import the necessary functions and classes:
95+
96+
```typescript
97+
import {
98+
generate,
99+
generateWithType,
100+
transcribe,
101+
Chat,
102+
createMemory,
103+
updateMemory,
104+
getAllMemories,
105+
generateImage,
106+
TextFileLoader,
107+
StringLoader,
108+
AudioLoader,
109+
kv,
110+
usage,
111+
t
112+
} from "polyfire-js";
113+
import PolyfireClientBuilder from "polyfire-js";
114+
```
115+
116+
## Features
117+
118+
### Text Generation
119+
120+
- **generate**: Generate text based on input.
121+
- **generateWithType**: Generate text with probabilistic types.
122+
123+
```typescript
124+
const options: GenerationOptions = { /* Generation options */ };
125+
const result = await generate("Your input text", options);
126+
```
127+
128+
### Transcription
129+
130+
- **transcribe**: Transcribe audio to text.
131+
132+
```typescript
133+
const transcription = await transcribe(audioFile);
134+
```
135+
136+
### Chat
137+
138+
- **Chat**: Class for handling chat functionalities.
139+
140+
```typescript
141+
const chat = new Chat();
142+
chat.sendMessage("Hello!");
143+
```
144+
145+
### Memory Management
146+
147+
- **createMemory**: Create embeddings for memory.
148+
- **updateMemory**: Update existing embeddings.
149+
- **getAllMemories**: Retrieve all embeddings.
150+
151+
```typescript
152+
const memory = createMemory(data);
153+
const updatedMemory = updateMemory(memoryId, newData);
154+
const allMemories = getAllMemories();
155+
```
156+
157+
### Image Generation
158+
159+
- **generateImage**: Generate images based on input.
160+
161+
```typescript
162+
const image = await generateImage("A beautiful sunset");
163+
```
164+
165+
### Data Loaders
166+
167+
- **TextFileLoader**: Load text files.
168+
- **StringLoader**: Load strings.
169+
- **AudioLoader**: Load audio files.
170+
171+
```typescript
172+
const textLoader = new TextFileLoader(filePath);
173+
const stringLoader = new StringLoader(stringData);
174+
const audioLoader = new AudioLoader(audioFile);
175+
```
176+
177+
### Key-Value Store Operations
178+
179+
- **kv.get**: Retrieve a value by key.
180+
- **kv.set**: Store a value by key.
181+
- **kv.del**: Delete a value by key.
182+
- **kv.all**: Retrieve all key-value pairs.
183+
184+
```typescript
185+
const value = await kv.get("key");
186+
await kv.set("key", "value");
187+
await kv.del("key");
188+
const allValues = await kv.all();
189+
```
190+
191+
### Usage Tracking
192+
193+
- **usage**: Track usage of the SDK.
194+
195+
```typescript
196+
const usageData = await usage();
197+
```
198+
199+
### Type Validation
200+
201+
- **t**: Type validation using `polyfact-io-ts`.
202+
203+
```typescript
204+
const isValid = t.validate(data, schema);
205+
```
206+
207+
### Client Builder
208+
209+
- **PolyfireClientBuilder**: Build the client.
210+
211+
```typescript
212+
const client = new PolyfireClientBuilder({ apiKey: "your-api-key" });
213+
```
214+
215+
## Example Usage
216+
217+
Here is a complete example of using the SDK:
218+
219+
```typescript
220+
import {
221+
generate,
222+
transcribe,
223+
createMemory,
224+
generateImage,
225+
kv,
226+
usage
227+
} from "polyfire-js";
228+
import PolyfireClientBuilder from "polyfire-js";
229+
230+
async function main() {
231+
// Text generation
232+
const text = await generate("Hello, world!");
233+
234+
// Transcription
235+
const transcription = await transcribe("path/to/audio/file");
236+
237+
// Memory management
238+
const memory = createMemory("Some data");
239+
240+
// Image generation
241+
const image = await generateImage("A beautiful sunset");
242+
243+
// Key-Value operations
244+
await kv.set("key", "value");
245+
const value = await kv.get("key");
246+
247+
// Usage tracking
248+
const usageData = await usage();
249+
250+
// Client builder
251+
const client = new PolyfireClientBuilder({ apiKey: "your-api-key" });
252+
}
253+
254+
main();
255+
```
102256
103-
We're open source! Make a good PR to the JS SDK or the API and we'll merge it.

0 commit comments

Comments
 (0)