Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Llama Index
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
run-llama
Llama Index
Commits
7e959cc8
Unverified
Commit
7e959cc8
authored
1 year ago
by
Rodrigo Nogueira
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Add system prompt (#11325)
* add system prompt workaround * remove workaround flag * fix lint
parent
d34e5a8b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
llama-index-integrations/llms/llama-index-llms-maritalk/llama_index/llms/maritalk/base.py
+15
-12
15 additions, 12 deletions
...ama-index-llms-maritalk/llama_index/llms/maritalk/base.py
with
15 additions
and
12 deletions
llama-index-integrations/llms/llama-index-llms-maritalk/llama_index/llms/maritalk/base.py
+
15
−
12
View file @
7e959cc8
...
@@ -45,11 +45,6 @@ class Maritalk(LLM):
...
@@ -45,11 +45,6 @@ class Maritalk(LLM):
description
=
"
Nucleus sampling parameter controlling the size of
"
description
=
"
Nucleus sampling parameter controlling the size of
"
"
the probability mass considered for sampling.
"
,
"
the probability mass considered for sampling.
"
,
)
)
system_message_workaround
:
bool
=
Field
(
default
=
True
,
description
=
"
Whether to include a workaround for system
"
"
message by adding it as a user message.
"
,
)
_endpoint
:
str
=
PrivateAttr
(
"
https://chat.maritaca.ai/api/chat/inference
"
)
_endpoint
:
str
=
PrivateAttr
(
"
https://chat.maritaca.ai/api/chat/inference
"
)
...
@@ -79,13 +74,21 @@ class Maritalk(LLM):
...
@@ -79,13 +74,21 @@ class Maritalk(LLM):
@llm_chat_callback
()
@llm_chat_callback
()
def
chat
(
self
,
messages
:
Sequence
[
ChatMessage
],
**
kwargs
:
Any
)
->
ChatResponse
:
def
chat
(
self
,
messages
:
Sequence
[
ChatMessage
],
**
kwargs
:
Any
)
->
ChatResponse
:
# Prepare the data payload for the Maritalk API
# Prepare the data payload for the Maritalk API
formatted_messages
=
[
formatted_messages
=
[]
{
for
msg
in
messages
:
"
role
"
:
"
user
"
if
msg
.
role
==
MessageRole
.
USER
else
"
assistant
"
,
if
msg
.
role
==
MessageRole
.
SYSTEM
:
"
content
"
:
msg
.
content
,
# Add system message as a user message
}
formatted_messages
.
append
({
"
role
"
:
"
user
"
,
"
content
"
:
msg
.
content
})
for
msg
in
messages
# Follow it by an assistant message acknowledging it, to maintain conversation flow
]
formatted_messages
.
append
({
"
role
"
:
"
assistant
"
,
"
content
"
:
"
ok
"
})
else
:
# Format user and assistant messages as before
formatted_messages
.
append
(
{
"
role
"
:
"
user
"
if
msg
.
role
==
MessageRole
.
USER
else
"
assistant
"
,
"
content
"
:
msg
.
content
,
}
)
data
=
{
data
=
{
"
messages
"
:
formatted_messages
,
"
messages
"
:
formatted_messages
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment