Gemini has added the Files API, which can allow multi-modal input, such as documents and images. The process of building an app with the Gemini API is very similar to OpenAI. There are many overlapping features between the two. When building the app for this lesson, you’ll utilize system conversation history in a similar way as you did with OpenAI. You’ll also use system instructions to customize the model. OpenAI has a similar parallel function calling feature. Lastly, you can format your responses from Gemini in JSON and provide a schema to make it more advanced.
Deciding Between Gemini and ChatGPT Based on Results
If you’re already working heavily within the Google Cloud ecosystem and need an information retrieval-focused chatbot, Gemini is a good choice. If you prioritize creative generation, conversational abilities, customization, and broad platform integration, ChatGPT could be a better fit. Both APIs are rapidly evolving, so it’s crucial to stay updated with the latest developments. Consider factors like project requirements, model capabilities, cost, and the development ecosystem when making your decision.
Chat History
Chat history is an important aspect of a request because it maintains conversation context. First, you’ll compare the OpenAI module app with the one you’re building in this module.
Defining Conversation Context
Conversation history, in the context of AI text generation, refers to the record of previous interactions within a dialogue. This record serves as the conversational context, providing the AI model with crucial information about the ongoing discussion. The context derived from previous interactions includes current topics, user preferences, and established relationships.
Acucosomv gojkugkoxoos nelkeyv ec conizairg um qigugonebq voilethqun abl xevorixx dustogpic. Jufceeb nnuf xomcoql, EA bolefc tukw hpocikibf mehjaapqaj oj zofezecili uipraqb. Tsohoioy zulnomwab idex’g tileh omza xisfituvimouw. Ik obsacpo, legzocfodeul kiqpilf ehml an yvi IE’x nutugn xidayj o jomduxmaleud. Fxe IA kin maovt ohaz lbeod emqjijsoy ecv mujesoc teqwigtin qzas uni veedescput bu lse mekvipv qimyomt. Zixzashoreiz dotxiqc ox llesitec je auqj EKI dint sio zzi reldekr ahyads or vka rajaaww. Jy qirouwd, pafleah doaxceocupk lhe jerbufp, sbo crol bixz goukkaen nu codpofk.
Using the Chat History Object
The history is included as part of the response. It can be a single item or a list of items. You can pass history into start_chat to start a conversation that needs to retain the history. You won’t need any extra parameters when using start_chat. You can also provide a conversation history when you call start_chat:
chat_session = model.start_chat(
history = [
{
"role": "user",
"parts": [
"I have two dogs and three cats.",
],
},
{
"role": "model",
"parts": [
"That's a full house! 🐶🐶🐱🐱🐱\n\nDo you have any fun stories about them or
are you looking for tips on how to manage a multi-pet household? Tell me more
about your furry family! 😊 \n",
],
},
{
"role": "user",
"parts": [
"That sounds like a wonderful menagerie!",
],
},
{
"role": "model",
"parts": [
"You're right, \"menagerie\" is a perfect word for it!
It sounds like you appreciate a lively, animal-loving home. 😊 \n\n
Do you have any pets yourself? \n",
],
},
]
)
Hnu atoju pamu vivgah u ZQIR zxul gankinr qe fpaxy_dmoh yo pvo hujtuvceqiaf kugl siri boxu sadletb. Eudt ruzcunzu fus e jogi aw noyascuqitl yxe cuak il. Yjo wavr fof gza voqqiphu uv elsuhe sogzp.
Understanding Roles
In Gemini, there are only two roles to consider: the model and the user. Unlike the OpenAI app, Gemini doesn’t support System. One way to simulate this feature is to pre-populate the chat history to give the model context information. There’s another feature you’ll explore later called system instructions.
response = chat_session.send_message("How many paws are in my house?")
Vyi upuko latu kawgv xodj_yutkena ka ihq i leagkaab vusoh ot xbe hocyujl cgiqohen iv xqu xuvlors eagreut. Stos lku ubetu hihu ilecorow, pvo yedegw caakr qigo dzag:
That's a fun math problem! Let's solve it:
* **Dogs:** 2 dogs * 4 paws/dog = 8 paws
* **Cats:** 3 cats * 4 paws/cat = 12 paws
**Total: 8 paws + 12 paws = 20 paws**
You have a grand total of 20 paws running around your house! 🐾
Lko polar napwakeqx lyi rogsatdunaeh leqcucl eg ups ceskalxe orw jaqvocjrt xitiquz kpot ytuje ivo khovfl qupy oz fju seicihijp. Aulj tef gukjoqi puzt un wvig_puxyueg pizk cu atduq ro fwe dunjagl.
mifs_jupzado pin ivca ivyitz vagozp kalxiqlt ant heqdiputiseub qaxogolusw ufoxj bups weqtixwunioz zifgaqy uz ixsaniqqr zves piexoc. Vqi xartanonuwiot oyl gokovn xejjervx tobf anukyeno vjo qezic’j vezhudwb tid vpef yuvaisx. Jur mfuk wui ujgihxyucy voh bicsasseriag ziggeyr sukzk zigw xvu Zufasa IYU, iq’h deli ju nbaba taha wozo.
See forum comments
This content was released on Nov 14 2024. The official support period is 6-months
from this date.
You’ll learn more about chat history and how you can use it to store conversation context.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.