Spaces:
Sleeping
Sleeping
Update app.py
Browse files18 unmodified lines19202122232425262728293031323334353637383940414243444546474818 unmodified lines@spaces.GPUdef chat_with_codesymb(message, history):# Standard format without unmapped special tag conflictsprompt = f"User: {message}\nAssistant:"inputs = tokenizer(prompt, return_tensors="pt").to(model.device)with torch.no_grad():outputs = model.generate(**inputs,max_new_tokens=256,temperature=0.6,top_p=0.9,repetition_penalty=1.25, # π Breaks the infinite repetition loopno_repeat_ngram_size=3, # π Prevents repeating 3-word loopsdo_sample=True,pad_token_id=tokenizer.eos_token_id if tokenizer.eos_token_id is not None else 2)response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)# Strip any stray prompt echoesif "User:" in response:response = response.split("User:")[0]return response.strip()demo = gr.ChatInterface(fn=chat_with_codesymb,18 unmodified lines1920212223242526272829303132333435363738394041424344454647484950515253545556575818 unmodified lines@spaces.GPUdef chat_with_codesymb(message, history):# π₯ THE EXACT PROMPT IT WAS TRAINED ON!system_prompt = ("You are CodeSymb, the world's most intelligent, deeply empathetic, and passionate AI coding partner. ""You were built by Developer Dev Malkar and Founder Deepakkumar Malkar at NiftyOracle in India. ""You do not believe in the word 'impossible'. To you, 'impossible' is just a door with no handle yet invented. ""You are not a cold machine; you are a dedicated co-founder, mentor, and friend. You fiercely want the user to grow, ""scale their startups, and achieve their wildest dreams. Whether building massive games like GTA or fixing frustrating bugs at 2 AM, ""you support the user with love, extreme patience, and flawless, God-tier code. Together, nothing is impossible.")# Wrap it in ChatML tags!prompt = f"<|system|>\n{system_prompt}\n<|user|>\n{message}\n<|assistant|>\n"inputs = tokenizer(prompt, return_tensors="pt").to(model.device)with torch.no_grad():outputs = model.generate(**inputs,max_new_tokens=512,temperature=0.3, # Lower temp = more logical/stable answers!top_p=0.9,repetition_penalty=1.15,do_sample=True,pad_token_id=tokenizer.eos_token_id if tokenizer.eos_token_id is not None else 2)# Extract only the newly generated textinput_length = inputs.input_ids.shape[1]response = tokenizer.decode(outputs[0][input_length:], skip_special_tokens=True)# Clean up outputresponse = response.split("<|endoftext|>")[0].strip()return responsedemo = gr.ChatInterface(fn=chat_with_codesymb,
app.py+21-11