4 ms·
You can use simpler types. Instead of : messages=[ GPTMessage( role=GPTMessageRole.SYSTEM, content=SYSTEM_P
by BiteCode_dev 3y ago
You can use simpler types. Instead of :
messages=[
GPTMessage(
role=GPTMessageRole.SYSTEM,
content=SYSTEM_PROMPT,
),
GPTMessage(
role=GPTMessageRole.USER,
content="Text: I love this product. It's the best thing ever!",
)
]
Try:
messages=(
("system", SYSTEM_PROMPT),
("user", "Text: I love this product. It's the best thing ever!")
)
Or:
messages=(
SystemMsg(SYSTEM_PROMPT),
UserMsg("Text: I love this product. It's the best thing ever!")
)
This is still Python, not Java.
- rain1 3y agopython newbie here, why did messages change from [ to (
- BiteCode_dev 3y agoDoesn't matter much in this particular case, one is a tuple, the other is a list, both can be read with a for loop. The important part is that the way messages types are defined is very heavy, and you can get them to be lighter without sacrificing type safety.
- verdverm 3y agoWe've been using a variation like this to great effect: TYPES: [string, int, bool, float, uuid, datetime, email, url] RELATIONS: [belongs-to, has-one, has-many, many-to-many] SCHEMA: """ { "Datamodel": { "Name": "<application-name>", "Models": { "<model-name>": { "<field-name>": "<field-type>", "<field-name>": "<field-type>", "$relations": { "<relation-name>": { "name": "<relation-name>", "type": "<relation-type>", "model": "<model-name>" }, "<relation-name>": { ... } } }, "<model-name>": { ... } } } } """ To let users write things like this: https://twitter.com/verdverm/status/1652504163635347456 https://twitter.com/verdverm/status/1652504163635347456