Skip to content

Commit 5b012ed

Browse files
committed
Add examples
1 parent 2842168 commit 5b012ed

File tree

2 files changed

+143
-2
lines changed

2 files changed

+143
-2
lines changed

README.md

+60-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,65 @@
88
pip install convertanything
99
```
1010

11-
## Usage
11+
## Usage Examples
12+
13+
### ezLocalai
14+
15+
To use with [ezLocalai](https://github.com/DevXT-LLC/ezlocalai) in Python, make sure your ezLocalai server is running then run the following code:
16+
17+
```python
18+
from convertanything import convertanything
19+
from pydantic import BaseModel
20+
from typing import List
21+
22+
23+
class Person(BaseModel):
24+
name: str
25+
age: int
26+
email: str
27+
interests: List[str]
28+
29+
30+
response = convertanything(
31+
input_string="Hi my name is John Doe, I am 30 years old, my email is [email protected] . I like to go fishing and watching football.",
32+
model=Person,
33+
api_key="Your ezlocalai API Key",
34+
server="http://localhost:8091",
35+
)
36+
print(response)
37+
```
38+
39+
### AGiXT
40+
41+
To use with [AGiXT](https://github.com/Josh-XT/AGiXT) in Python, make sure your AGiXT server is running then run the following code:
42+
43+
```python
44+
from convertanything import convertanything
45+
from pydantic import BaseModel
46+
from typing import List
47+
48+
49+
class Person(BaseModel):
50+
name: str
51+
age: int
52+
email: str
53+
interests: List[str]
54+
55+
56+
response = convertanything(
57+
input_string="Hi my name is John Doe, I am 30 years old, my email is [email protected] . I like to go fishing and watching football.",
58+
model=Person,
59+
api_key="Your AGiXT API Key",
60+
server="http://localhost:7437",
61+
llm="Your AGiXT Agent Name",
62+
prompt_name="User Input",
63+
)
64+
print(response)
65+
```
66+
67+
### OpenAI
68+
69+
If you have an OpenAI API key, you can use it as follows with OpenAI language models:
1270

1371
```python
1472
from convertanything import convertanything
@@ -25,6 +83,7 @@ response = convertanything(
2583
input_string="Hi my name is John Doe, I am 30 years old, my email is [email protected] . I like to go fishing.",
2684
model=Person,
2785
api_key="Your OpenAI API Key",
86+
llm="gpt-3.5-turbo",
2887
)
2988
print(response)
3089
```

example.ipynb

+83-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515
"Alternatively, to use with OpenAI API, you can remove the `server` and `llm` parameters and enter your OpenAI API key in the `api_key` parameter to use OpenAI API with the `gpt-3.5-turbo-16k` model or define which LLM you want to use with the `llm` parameter.\n"
1616
]
1717
},
18+
{
19+
"cell_type": "markdown",
20+
"metadata": {},
21+
"source": [
22+
"### ezLocalai\n",
23+
"\n",
24+
"To use with [ezLocalai](https://github.com/DevXT-LLC/ezlocalai) in Python, make sure your ezLocalai server is running then run the following code:\n"
25+
]
26+
},
1827
{
1928
"cell_type": "code",
2029
"execution_count": 4,
@@ -46,7 +55,80 @@
4655
" model=Person,\n",
4756
" api_key=\"Your ezlocalai API Key\",\n",
4857
" server=\"http://localhost:8091\",\n",
49-
" llm=\"ezlocalai\",\n",
58+
")\n",
59+
"print(response)"
60+
]
61+
},
62+
{
63+
"cell_type": "markdown",
64+
"metadata": {},
65+
"source": [
66+
"### AGiXT\n",
67+
"\n",
68+
"To use with [AGiXT](https://github.com/Josh-XT/AGiXT) in Python, make sure your AGiXT server is running then run the following code:\n"
69+
]
70+
},
71+
{
72+
"cell_type": "code",
73+
"execution_count": null,
74+
"metadata": {},
75+
"outputs": [],
76+
"source": [
77+
"from convertanything import convertanything\n",
78+
"from pydantic import BaseModel\n",
79+
"from typing import List\n",
80+
"\n",
81+
"\n",
82+
"class Person(BaseModel):\n",
83+
" name: str\n",
84+
" age: int\n",
85+
" email: str\n",
86+
" interests: List[str]\n",
87+
"\n",
88+
"\n",
89+
"response = convertanything(\n",
90+
" input_string=\"Hi my name is John Doe, I am 30 years old, my email is [email protected] . I like to go fishing and watching football.\",\n",
91+
" model=Person,\n",
92+
" api_key=\"Your AGiXT API Key\",\n",
93+
" server=\"http://localhost:7437\",\n",
94+
" llm=\"Your AGiXT Agent Name\",\n",
95+
" prompt_name=\"User Input\",\n",
96+
")\n",
97+
"print(response)"
98+
]
99+
},
100+
{
101+
"cell_type": "markdown",
102+
"metadata": {},
103+
"source": [
104+
"### OpenAI\n",
105+
"\n",
106+
"If you have an OpenAI API key, you can use it as follows with OpenAI language models:\n"
107+
]
108+
},
109+
{
110+
"cell_type": "code",
111+
"execution_count": null,
112+
"metadata": {},
113+
"outputs": [],
114+
"source": [
115+
"from convertanything import convertanything\n",
116+
"from pydantic import BaseModel\n",
117+
"from typing import List\n",
118+
"\n",
119+
"\n",
120+
"class Person(BaseModel):\n",
121+
" name: str\n",
122+
" age: int\n",
123+
" email: str\n",
124+
" interests: List[str]\n",
125+
"\n",
126+
"\n",
127+
"response = convertanything(\n",
128+
" input_string=\"Hi my name is John Doe, I am 30 years old, my email is [email protected] . I like to go fishing.\",\n",
129+
" model=Person,\n",
130+
" api_key=\"Your OpenAI API Key\",\n",
131+
" llm=\"gpt-3.5-turbo\",\n",
50132
")\n",
51133
"print(response)"
52134
]

0 commit comments

Comments
 (0)