llama-index-llms-openai 0.2.12__py3-none-any.whl → 0.2.13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,6 +54,8 @@ GPT4_MODELS: Dict[str, int] = {
54
54
  "gpt-4o": 128000,
55
55
  "gpt-4o-2024-05-13": 128000,
56
56
  "gpt-4o-2024-08-06": 128000,
57
+ # Intended for research and evaluation
58
+ "chatgpt-4o-latest": 128000,
57
59
  "gpt-4o-mini": 128000,
58
60
  "gpt-4o-mini-2024-07-18": 128000,
59
61
  # 0613 models (function calling):
@@ -0,0 +1,149 @@
1
+ Metadata-Version: 2.1
2
+ Name: llama-index-llms-openai
3
+ Version: 0.2.13
4
+ Summary: llama-index llms openai integration
5
+ License: MIT
6
+ Author: llama-index
7
+ Requires-Python: >=3.8.1,<4.0
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Requires-Dist: llama-index-core (>=0.11.7,<0.12.0)
15
+ Requires-Dist: openai (>=1.40.0,<2.0.0)
16
+ Description-Content-Type: text/markdown
17
+
18
+ # LlamaIndex Llms Integration: Openai
19
+
20
+ ## Installation
21
+
22
+ To install the required package, run:
23
+
24
+ ```bash
25
+ %pip install llama-index-llms-openai
26
+ ```
27
+
28
+ ## Setup
29
+
30
+ 1. Set your OpenAI API key as an environment variable. You can replace `"sk-..."` with your actual API key:
31
+
32
+ ```python
33
+ import os
34
+
35
+ os.environ["OPENAI_API_KEY"] = "sk-..."
36
+ ```
37
+
38
+ ## Basic Usage
39
+
40
+ ### Generate Completions
41
+
42
+ To generate a completion for a prompt, use the `complete` method:
43
+
44
+ ```python
45
+ from llama_index.llms.openai import OpenAI
46
+
47
+ resp = OpenAI().complete("Paul Graham is ")
48
+ print(resp)
49
+ ```
50
+
51
+ ### Chat Responses
52
+
53
+ To send a chat message and receive a response, create a list of `ChatMessage` instances and use the `chat` method:
54
+
55
+ ```python
56
+ from llama_index.core.llms import ChatMessage
57
+
58
+ messages = [
59
+ ChatMessage(
60
+ role="system", content="You are a pirate with a colorful personality."
61
+ ),
62
+ ChatMessage(role="user", content="What is your name?"),
63
+ ]
64
+ resp = OpenAI().chat(messages)
65
+ print(resp)
66
+ ```
67
+
68
+ ## Streaming Responses
69
+
70
+ ### Stream Complete
71
+
72
+ To stream responses for a prompt, use the `stream_complete` method:
73
+
74
+ ```python
75
+ from llama_index.llms.openai import OpenAI
76
+
77
+ llm = OpenAI()
78
+ resp = llm.stream_complete("Paul Graham is ")
79
+ for r in resp:
80
+ print(r.delta, end="")
81
+ ```
82
+
83
+ ### Stream Chat
84
+
85
+ To stream chat responses, use the `stream_chat` method:
86
+
87
+ ```python
88
+ from llama_index.llms.openai import OpenAI
89
+ from llama_index.core.llms import ChatMessage
90
+
91
+ llm = OpenAI()
92
+ messages = [
93
+ ChatMessage(
94
+ role="system", content="You are a pirate with a colorful personality."
95
+ ),
96
+ ChatMessage(role="user", content="What is your name?"),
97
+ ]
98
+ resp = llm.stream_chat(messages)
99
+ for r in resp:
100
+ print(r.delta, end="")
101
+ ```
102
+
103
+ ## Configure Model
104
+
105
+ You can specify a particular model when creating the `OpenAI` instance:
106
+
107
+ ```python
108
+ llm = OpenAI(model="gpt-3.5-turbo")
109
+ resp = llm.complete("Paul Graham is ")
110
+ print(resp)
111
+
112
+ messages = [
113
+ ChatMessage(
114
+ role="system", content="You are a pirate with a colorful personality."
115
+ ),
116
+ ChatMessage(role="user", content="What is your name?"),
117
+ ]
118
+ resp = llm.chat(messages)
119
+ print(resp)
120
+ ```
121
+
122
+ ## Asynchronous Usage
123
+
124
+ You can also use asynchronous methods for completion:
125
+
126
+ ```python
127
+ from llama_index.llms.openai import OpenAI
128
+
129
+ llm = OpenAI(model="gpt-3.5-turbo")
130
+ resp = await llm.acomplete("Paul Graham is ")
131
+ print(resp)
132
+ ```
133
+
134
+ ## Set API Key at a Per-Instance Level
135
+
136
+ If desired, you can have separate LLM instances use different API keys:
137
+
138
+ ```python
139
+ from llama_index.llms.openai import OpenAI
140
+
141
+ llm = OpenAI(model="gpt-3.5-turbo", api_key="BAD_KEY")
142
+ resp = OpenAI().complete("Paul Graham is ")
143
+ print(resp)
144
+ ```
145
+
146
+ ### LLM Implementation example
147
+
148
+ https://docs.llamaindex.ai/en/stable/examples/llm/openai/
149
+
@@ -0,0 +1,6 @@
1
+ llama_index/llms/openai/__init__.py,sha256=vm3cIBSGkBFlE77GyfyN0EhpJcnJZN95QMhPN53EkbE,148
2
+ llama_index/llms/openai/base.py,sha256=tyapzQX3I3WMgH4qwAKU4A7eaa73lnJh9Bc34pvMD0k,35197
3
+ llama_index/llms/openai/utils.py,sha256=CLKXZlnafL7i0hNQrMS21GmyPG3Mj5NpSOvAksI-4p8,15835
4
+ llama_index_llms_openai-0.2.13.dist-info/METADATA,sha256=3gRM0x9SQT9tWekmHjS-YrKgRdTqKuMfO5_dJwxX0OQ,3323
5
+ llama_index_llms_openai-0.2.13.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
6
+ llama_index_llms_openai-0.2.13.dist-info/RECORD,,
@@ -1,19 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: llama-index-llms-openai
3
- Version: 0.2.12
4
- Summary: llama-index llms openai integration
5
- License: MIT
6
- Author: llama-index
7
- Requires-Python: >=3.8.1,<4.0
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Programming Language :: Python :: 3.9
11
- Classifier: Programming Language :: Python :: 3.10
12
- Classifier: Programming Language :: Python :: 3.11
13
- Classifier: Programming Language :: Python :: 3.12
14
- Requires-Dist: llama-index-core (>=0.11.7,<0.12.0)
15
- Requires-Dist: openai (>=1.40.0,<2.0.0)
16
- Description-Content-Type: text/markdown
17
-
18
- # LlamaIndex Llms Integration: Openai
19
-
@@ -1,6 +0,0 @@
1
- llama_index/llms/openai/__init__.py,sha256=vm3cIBSGkBFlE77GyfyN0EhpJcnJZN95QMhPN53EkbE,148
2
- llama_index/llms/openai/base.py,sha256=tyapzQX3I3WMgH4qwAKU4A7eaa73lnJh9Bc34pvMD0k,35197
3
- llama_index/llms/openai/utils.py,sha256=o1_DwqNIvmrL8KcF6IfBXOOll0aXVgGNhVPhbUYTWic,15759
4
- llama_index_llms_openai-0.2.12.dist-info/METADATA,sha256=OrUK6ucgrWE7bz791ZY3t60lafxD2EPMLL5PcA7O6As,649
5
- llama_index_llms_openai-0.2.12.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
6
- llama_index_llms_openai-0.2.12.dist-info/RECORD,,