You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: integrations/watsonx/examples/chat_generator_example.py
+67-31Lines changed: 67 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -110,26 +110,35 @@ def _run_async(coro_func):
110
110
# === Watsonx Chat Generator Demo ===
111
111
112
112
# --- Basic Chat ---
113
-
# Quantum computing is a fascinating technology that uses the principles of quantum mechanics to perform calculations and operations on data. Here's a simple explanation:
113
+
# Quantum computing is a fascinating technology that uses the principles of quantum mechanics to perform calculations
114
+
# and operations on data. Here's a simple explanation:
114
115
115
116
# **Classical computers vs. Quantum Computers**
116
117
117
-
# A classical computer uses "bits" to store and process information. A bit is either 0 or 1, and it's like a light switch - it's either on or off. A quantum computer uses "qubits" (quantum bits), which can exist in multiple states at the same time. This means a quantum computer can process a vast number of possibilities simultaneously.
118
+
# A classical computer uses "bits" to store and process information. A bit is either 0 or 1, and it's like a light
119
+
# switch - it's either on or off. A quantum computer uses "qubits" (quantum bits), which can exist in multiple states
120
+
# at the same time. This means a quantum computer can process a vast number of possibilities simultaneously.
118
121
119
122
# **How Quantum Computers Work**
120
123
121
-
# Imagine you have a deck of cards with 52 cards in it. A classical computer would look at each card one by one, and if it finds a match, it would move on to the next card. A quantum computer, on the other hand, can look at all the cards simultaneously and find matches instantly.
124
+
# Imagine you have a deck of cards with 52 cards in it. A classical computer would look at each card one by one, and
125
+
# if it finds a match, it would move on to the next card. A quantum computer, on the other hand, can look at all the
126
+
# cards simultaneously and find matches instantly.
122
127
123
-
# This is because qubits can exist in multiple states (0, 1, and both at the same time) and can be connected in a way that allows them to communicate with each other instantly, no matter how far apart they are.
128
+
# This is because qubits can exist in multiple states (0, 1, and both at the same time) and can be connected in a way
129
+
# that allows them to communicate with each other instantly, no matter how far apart they are.
124
130
125
131
# **Quantum Computing Steps**
126
132
127
133
# Here's a simplified step-by-step explanation of how a quantum computer works:
128
134
129
-
# 1. **Qubit Preparation**: The qubits are created and prepared in a special way to represent the problem we want to solve.
130
-
# 2. **Quantum Gates**: The qubits are then passed through a series of quantum gates, which are like the "switches" that control the qubits' behavior.
135
+
# 1. **Qubit Preparation**: The qubits are created and prepared in a special way to represent the problem we want to
136
+
# solve.
137
+
# 2. **Quantum Gates**: The qubits are then passed through a series of quantum gates, which are like the "switches"
138
+
# that control the qubits' behavior.
131
139
# 3. **Quantum Measurement**: The qubits are measured, and the outcome is determined.
132
-
# 4. **Data Processing**: The data is processed using the qubits' quantum gates, which allows for fast and efficient calculations.
140
+
# 4. **Data Processing**: The data is processed using the qubits' quantum gates, which allows for fast and efficient
141
+
# calculations.
133
142
134
143
# **What Quantum Computers Can Do**
135
144
@@ -148,31 +157,44 @@ def _run_async(coro_func):
148
157
# * **Scalability**: Currently, quantum computers are not scalable enough to solve complex problems.
149
158
# * **Quantum Noise**: Random fluctuations in qubits can affect the accuracy of quantum computations.
# I'm not aware of any real-time weather information. However, I can suggest some ways for you to find out the current weather in Berlin. You can:
164
+
# I'm not aware of any real-time weather information. However, I can suggest some ways for you to find out the current
165
+
# weather in Berlin. You can:
155
166
156
-
# * Check online weather websites such as AccuWeather, Weather.com, or the German national weather service, Deutscher Wetterdienst (DWD).
167
+
# * Check online weather websites such as AccuWeather, Weather.com, or the German national weather service, Deutscher
168
+
# Wetterdienst (DWD).
157
169
# * Use a mobile app such as Dark Sky or Weather Underground.
158
170
# * Tune into local news or radio stations for weather updates.
159
171
160
172
# If you'd like, I can help you find the most up-to-date weather information for Berlin.
161
173
162
174
# --- Streaming Chat ---
163
175
164
-
# Full message: I don't have the capability to write poems. However, I can assist you with generating a poem about artificial intelligence if you'd like.
176
+
# Full message: I don't have the capability to write poems. However, I can assist you with generating a poem about
177
+
# artificial intelligence if you'd like.
165
178
166
179
# --- Async Chat ---
167
180
# Here's an overview of the history of the internet:
168
181
169
-
# * **Early beginnings:** The internet has its roots in the 1960s, when the United States Department of Defense's Advanced Research Projects Agency (ARPA) funded a project to create a network of computers that could communicate with each other. This project, called ARPANET, was the first operational packet switching network.
170
-
# * **Network expansion:** In the 1970s and 1980s, other networks, such as the National Science Foundation Network (NSFNET), were established, connecting universities and research institutions across the United States.
171
-
# * **The World Wide Web (WWW):** In 1989, Tim Berners-Lee invented the World Wide Web, which revolutionized the way people access and share information online. The web made it easy for users to navigate and access information using web browsers and hyperlinks.
172
-
# * **Internet growth:** The 1990s saw the rise of commercial internet services, such as America Online (AOL) and CompuServe. This led to the growth of the internet as a mainstream technology.
173
-
# * **Globalization:** The internet became increasingly global, with the establishment of international networks and the development of new technologies, such as broadband and mobile internet.
174
-
# * **Social media and online communities:** The 2000s saw the rise of social media platforms, such as Facebook and Twitter, which enabled people to connect with each other and share information online.
175
-
# * **The internet today:** The internet is now a global network of billions of interconnected devices, with applications ranging from online shopping and education to social media and entertainment.
182
+
# * **Early beginnings:** The internet has its roots in the 1960s, when the United States Department of Defense's
183
+
# Advanced Research Projects Agency (ARPA) funded a project to create a network of computers that could
184
+
# communicate with each other. This project, called ARPANET, was the first operational packet switching network.
185
+
# * **Network expansion:** In the 1970s and 1980s, other networks, such as the National Science Foundation Network
186
+
# (NSFNET), were established, connecting universities and research institutions across the United States.
187
+
# * **The World Wide Web (WWW):** In 1989, Tim Berners-Lee invented the World Wide Web, which revolutionized the
188
+
# way people access and share information online. The web made it easy for users to navigate and access
189
+
# information using web browsers and hyperlinks.
190
+
# * **Internet growth:** The 1990s saw the rise of commercial internet services, such as America Online (AOL) and
191
+
# CompuServe. This led to the growth of the internet as a mainstream technology.
192
+
# * **Globalization:** The internet became increasingly global, with the establishment of international networks
193
+
# and the development of new technologies, such as broadband and mobile internet.
194
+
# * **Social media and online communities:** The 2000s saw the rise of social media platforms, such as Facebook
195
+
# and Twitter, which enabled people to connect with each other and share information online.
196
+
# * **The internet today:** The internet is now a global network of billions of interconnected devices, with
197
+
# applications ranging from online shopping and education to social media and entertainment.
176
198
177
199
# Here's a summary of the key events and milestones in the history of the internet:
178
200
@@ -183,36 +205,50 @@ def _run_async(coro_func):
183
205
# * 1995: Broadband internet becomes available
184
206
# * 2000: Social media platforms begin to emerge
185
207
# * 2007: Facebook becomes one of the most popular social media platforms
186
-
# * 2010s: The internet continues to evolve with the development of new technologies, such as mobile internet and artificial intelligence.
208
+
# * 2010s: The internet continues to evolve with the development of new technologies, such as mobile internet and
209
+
# artificial intelligence.
187
210
188
211
# --- Async Streaming Chat ---
189
212
190
213
# Full message: **Tool Call: Blockchain Technology**
191
214
192
-
# The tool call "Blockchain Technology" is a fundamental concept in the field of cryptography and distributed ledger technology. Here's a brief explanation:
215
+
# The tool call "Blockchain Technology" is a fundamental concept in the field of cryptography and distributed ledger
216
+
# technology. Here's a brief explanation:
193
217
194
-
# Blockchain technology is a decentralized, digital ledger that records transactions across a network of computers in a secure and transparent manner. It allows for the creation of a permanent, immutable record of all transactions, making it ideal for applications such as cryptocurrency, supply chain management, and voting systems.
218
+
# Blockchain technology is a decentralized, digital ledger that records transactions across a network of computers in
219
+
# a secure and transparent manner. It allows for the creation of a permanent, immutable record of all transactions,
220
+
# making it ideal for applications such as cryptocurrency, supply chain management, and voting systems.
195
221
196
222
# Here's a high-level overview of how blockchain technology works:
197
223
198
-
# 1. **Distributed Ledger**: A blockchain is a distributed ledger that is maintained by a network of computers (nodes) that are connected to each other through a peer-to-peer network.
199
-
# 2. **Transactions**: When a user wants to make a transaction, they create a new entry in the blockchain by broadcasting the transaction to the network of nodes.
200
-
# 3. **Verification**: Each node verifies the transaction by checking its validity and ensuring that it is not tampered with.
224
+
# 1. **Distributed Ledger**: A blockchain is a distributed ledger that is maintained by a network of computers
225
+
# (nodes) that are connected to each other through a peer-to-peer network.
226
+
# 2. **Transactions**: When a user wants to make a transaction, they create a new entry in the blockchain by
227
+
# broadcasting the transaction to the network of nodes.
228
+
# 3. **Verification**: Each node verifies the transaction by checking its validity and ensuring that it is not
229
+
# tampered with.
201
230
# 4. **Block Creation**: Once a node verifies the transaction, it creates a new block and adds it to the blockchain.
202
-
# 5. **Blockchain Update**: Each node updates its copy of the blockchain with the new block, ensuring that all nodes have the same version of the blockchain.
231
+
# 5. **Blockchain Update**: Each node updates its copy of the blockchain with the new block, ensuring that all nodes
232
+
# have the same version of the blockchain.
203
233
204
234
# **Benefits of Blockchain Technology**
205
235
206
-
# 1. **Security**: Blockchain technology is secure due to the use of cryptography and the decentralized nature of the network.
236
+
# 1. **Security**: Blockchain technology is secure due to the use of cryptography and the decentralized nature of
237
+
# the network.
207
238
# 2. **Transparency**: All transactions are recorded in a public ledger, making it transparent and tamper-proof.
208
-
# 3. **Immutable**: The blockchain is an immutable record, meaning that once a transaction is recorded, it cannot be altered or deleted.
209
-
# 4. **Decentralization**: Blockchain technology is decentralized, meaning that there is no single point of control or authority.
239
+
# 3. **Immutable**: The blockchain is an immutable record, meaning that once a transaction is recorded, it cannot
240
+
# be altered or deleted.
241
+
# 4. **Decentralization**: Blockchain technology is decentralized, meaning that there is no single point of control
242
+
# or authority.
210
243
211
244
# **Real-World Applications of Blockchain Technology**
212
245
213
246
# 1. **Cryptocurrencies**: Blockchain technology is the foundation for cryptocurrencies such as Bitcoin and Ethereum.
214
-
# 2. **Supply Chain Management**: Blockchain technology is being used to track the movement of goods and materials throughout the supply chain.
247
+
# 2. **Supply Chain Management**: Blockchain technology is being used to track the movement of goods and materials
248
+
# throughout the supply chain.
215
249
# 3. **Voting Systems**: Blockchain technology is being used to create secure and transparent voting systems.
216
-
# 4. **Identity Verification**: Blockchain technology is being used to create secure and decentralized identity verification systems.
250
+
# 4. **Identity Verification**: Blockchain technology is being used to create secure and decentralized identity
251
+
# verification systems.
217
252
218
-
# In summary, blockchain technology is a decentralized, digital ledger that records transactions in a secure and transparent manner. Its benefits include security, transparency, immutability, and decentralization.
253
+
# In summary, blockchain technology is a decentralized, digital ledger that records transactions in a secure and
254
+
# transparent manner. Its benefits include security, transparency, immutability, and decentralization.
Copy file name to clipboardExpand all lines: integrations/watsonx/examples/embedders_example.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -53,4 +53,5 @@
53
53
# Step 7: Print result
54
54
55
55
### Result
56
-
# Document(id=62fad790ad2af927af9432c87330ed2ea5e31332cdec8e9d6235a5105ab0aaf5, content: 'My name is Wolfgang and I live in Berlin', score: 0.7287276769333577)
56
+
# Document(id=62fad790ad2af927af9432c87330ed2ea5e31332cdec8e9d6235a5105ab0aaf5, content: 'My name is Wolfgang and I
Copy file name to clipboardExpand all lines: integrations/watsonx/examples/generator_example.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -50,5 +50,7 @@
50
50
51
51
52
52
##Result for steaming generator
53
-
##Full response: The AI assistant is a friendly and helpful robot that can help you with many tasks, such as setting reminders,
54
-
## managing your calendar, and creating to-do lists. You can also use the AI assistant to search for information online, or just have fun conversations with it.
53
+
##Full response: The AI assistant is a friendly and helpful robot that can help you with many tasks, such as setting
54
+
# reminders,
55
+
## managing your calendar, and creating to-do lists. You can also use the AI assistant to search for information
0 commit comments