[1180c1]: / llava / __pycache__ / conversation.cpython-310.pyc

Download this file

62 lines (61 with data), 9.8 kB

o

ÔPÑdø6ã
@sRddlZddlmZmZddlmZmZGdd„deƒZejGdd„dƒƒZ	e	dd	d
dej
dd
Ze	dd	ddej
dd
Ze	dddddej
dddZe	ddddej
dddZe	dd	ddej
dd
Ze	dd	ddej
dd
Ze	dd	ddej
dd
Ze	dd	ddej
dd
Ze	dddddej
dddZeZeeeeeeeedœZedkr§ee ¡ƒdSdS) éN)ÚautoÚEnum)ÚListÚTuplec@seZdZdZeƒZeƒZdS)ÚSeparatorStylezDifferent separator style.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rÚSINGLEÚTWO©r
r
úN/data/chunyl/research/project/2023/llava_biomed/LLaVA_v1/llava/conversation.pyrs
rc@s®eZdZUdZeed<eeed<eeeed<eed<ej	Z
eed<dZeed<d	Zeed
<dZ
eed<d
Zeed<dd„Zdd„Zddd„Zdd„Zdd„Zdd„Zd	S)ÚConversationz,A class that keeps all conversation history.ÚsystemÚrolesÚmessagesÚoffsetÚ	sep_styleú###ÚsepNÚsep2ÚUnknownÚversionFÚ	skip_nextcCs|jtjkr5|j|j}|jD]#\}}|r,t|ƒtur |\}}}||d||j7}q||d7}q|S|jtjkrx|j|j	g}|j|d}t
|jƒD](\}\}}|rot|ƒtur`|\}}}||d|||d7}qM||d7}qM|Std|j›ƒ‚)Nz: ú:rézInvalid style: )rrrrrrÚtypeÚtuplerrÚ	enumerateÚ
ValueError)ÚselfÚretÚroleÚmessageÚ_ÚsepsÚir
r
rÚ
get_prompts(

zConversation.get_promptcCs|j ||g¡dS)N)rÚappend)r!r#r$r
r
rÚappend_message3szConversation.append_messagecstg}t|j|jd…ƒD]«\}\}}|ddkr·t|ƒtur·ddl}ddlm}ddlm	‰|\}}}	|	dkrCd‡fdd„	}
|
|ƒ}n|	d	krHn|	d
krR| 
d¡}ntd|	›ƒ‚t|j
ƒt|j
ƒ}}||}
d
\}}tt||
||ƒƒ}t||
ƒ}|j
\}}||kr‹||}}n||}}| 
||f¡}|rŸ| |¡q|ƒ}|j|dd| | ¡¡ ¡}| |¡q|S)Nrr©ÚBytesIO©ÚImageÚPad©ézétéhcs~|j\}}||kr|S||kr'ˆ |j||f|¡}| |d||df¡|Sˆ |j||f|¡}| |||ddf¡|S)Nrr)ÚsizeÚnewÚmodeÚpaste)Úpil_imgÚbackground_colorÚwidthÚheightÚresultr-r
rÚ
expand2square@s
z.Conversation.get_images.<locals>.expand2squareZCropÚResize)éàr?zInvalid image_process_mode: ©i iÚJPEG©Úformat)r0)rrrrrÚbase64Úior,ÚPILr.Úresizer Úmaxr4ÚminÚintr)ÚsaveÚ	b64encodeÚgetvalueÚdecode)r!Z
return_pilÚimagesr'r#ÚmsgrDr,ÚimageÚimage_process_moder=Úmax_hwÚmin_hwÚaspect_ratioÚmax_lenÚmin_lenÚ
shortest_edgeÚlongest_edgeÚWÚHÚbufferedÚimg_b64_strr
r-rÚ
get_images6sD 




€zConversation.get_imagescCs6g}t|j|jd…ƒD]Œ\}\}}|ddkr’t|ƒturŠddl}ddlm}|\}}}t|j	ƒt
|j	ƒ}	}
|	|
}d\}}
tt
|||
|
ƒƒ}t||ƒ}|j	\}}||kr_||}}n||}}| ||f¡}|ƒ}|j
|dd| | ¡¡ ¡}d|›d}| d	|¡}| |dg¡q||d
d
<q|S)Nrrr+r@rArBz <img src="data:image/png;base64,z" alt="user upload image" />z<image>éÿÿÿÿ)rrrrrrDrEr,rHr4rIrJrGrKrLrMrNÚreplacer))r!r"r'r#rPrDr,rQrRrSrTrUrVrWrXrYrZr[r\r]Zimg_strr
r
rÚto_gradio_chatbotgs2 


zConversation.to_gradio_chatbotc	Cs.t|j|jdd„|jDƒ|j|j|j|jdS)NcSsg|]\}}||g‘qSr
r
©Ú.0ÚxÚyr
r
rÚ
<listcomp>‰sz%Conversation.copy.<locals>.<listcomp>©rrrrrrr)rrrrrrrr©r!r
r
rÚcopy…sùzConversation.copycCsVt| ¡ƒdkr|j|jdd„|jDƒ|j|j|jdœS|j|j|j|j|j|jdœS)NrcSs,g|]\}}|t|ƒtur|dn|g‘qS)r)rrrbr
r
rrf”s,z%Conversation.dict.<locals>.<listcomp>)rrrrrr)Úlenr^rrrrrrrhr
r
rÚdictsú	úzConversation.dict)F)rrr	r
ÚstrÚ__annotations__rrJrrrrrrrÚboolr(r*r^rarirkr
r
r
rrs"

1
rzœA chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.)ÚHumanÚ	Assistant))roz$Give three tips for staying healthy.)rpa	Sure, here are three tips for staying healthy:
1. Exercise regularly: Regular physical activity can help improve your overall health and wellbeing. It can also help reduce your risk of chronic conditions such as obesity, diabetes, heart disease, and certain cancers. Aim for at least 150 minutes of moderate-intensity aerobic exercise or 75 minutes of vigorous-intensity aerobic exercise per week, along with muscle-strengthening activities at least two days per week.
2. Eat a balanced diet: Eating a balanced diet that is rich in fruits, vegetables, whole grains, lean proteins, and healthy fats can help support your overall health. Try to limit your intake of processed and high-sugar foods, and aim to drink plenty of water throughout the day.
3. Get enough sleep: Getting enough quality sleep is essential for your physical and mental health. Adults should aim for seven to nine hours of sleep per night. Establish a regular sleep schedule and try to create a relaxing bedtime routine to help improve the quality of your sleep.rr)rrrrrr))rozPWhat are the key differences between renewable and non-renewable energy sources?)rpagRenewable energy sources are those that can be replenished naturally in a relatively short amount of time, such as solar, wind, hydro, geothermal, and biomass. Non-renewable energy sources, on the other hand, are finite and will eventually be depleted, such as coal, oil, and natural gas. Here are some key differences between renewable and non-renewable energy sources:
1. Availability: Renewable energy sources are virtually inexhaustible, while non-renewable energy sources are finite and will eventually run out.
2. Environmental impact: Renewable energy sources have a much lower environmental impact than non-renewable sources, which can lead to air and water pollution, greenhouse gas emissions, and other negative effects.
3. Cost: Renewable energy sources can be more expensive to initially set up, but they typically have lower operational costs than non-renewable sources.
4. Reliability: Renewable energy sources are often more reliable and can be used in more remote locations than non-renewable sources.
5. Flexibility: Renewable energy sources are often more flexible and can be adapted to different situations and needs, while non-renewable sources are more rigid and inflexible.
6. Sustainability: Renewable energy sources are more sustainable over the long term, while non-renewable sources are not, and their depletion can lead to economic and social instability.
zšA chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.)ÚUSERZ	ASSISTANTÚv1r
Ú z</s>)rrrrrrrrzBEGINNING OF CONVERSATION:)rqZGPTrga(You are LLaVA-Med, a large language and vision assistant trained by a group of researchers at Microsoft, based on the general domain LLaVA architecture.You are designed to assist human with a variety of medical and clinical research tasks using natural language.Follow the instructions carefully.))rozHi!©rpz%Hi there!  How can I help you today?
a{You are LLaVA-Med, a large language and vision assistant trained by a group of researchers at Microsoft, based on the general domain LLaVA architecture.You are able to understand the visual content that the user provides, and assist the user with a variety of medical and clinical tasks using natural language.Follow the instructions carefully and explain your answers in detail.))rozHi!

### Response:rta„You are LLaVA-Med, a large language and vision assistant trained by a group of researchers at Microsoft, based on the general domain LLaVA architecture.You are able to understand the visual content that the user provides, and assist the user with a variety of medical and clinical research tasks using natural language.Follow the instructions carefully and explain your answers in detail.)ÚdefaultÚsimpleZ
simple_legacyZ
multimodalZllava_v1rrZbair_v1Úvicuna_v1_1Ú__main__)ÚdataclassesÚenumrrÚtypingrrrÚ	dataclassrrZconv_v1Z	conv_v1_2rZconv_vicuna_v1_1Zconv_bair_v1Zsimple_conv_medZsimple_convZsimple_conv_multimodalZsimple_conv_legacyZ
conv_llava_v1Údefault_conversationÚconv_templatesrÚprintr(r
r
r
rÚ<module>sÂèä÷ù
õö
õõö
öÿ