Skip to content

Commit

Permalink
add provider and model name to model inputs (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
shincap8 authored Feb 25, 2025
1 parent 63ef61e commit 8a46375
Showing 1 changed file with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ import { CreateInterfaceContext } from "new_front/context/CreateInterface/Contex
import BasicInstructions from "new_front/components/Inputs/BasicInstructions";
import GeneralButton from "new_front/components/Buttons/GeneralButton";

const ChatWithInstructions: FC<
interface ModelNameMap {
[key: string]: {
model_name: string;
};
}

const ChatRandomWithInstructions: FC<
ContextAnnotationFactoryType & ContextConfigType
> = ({
taskId,
Expand All @@ -34,7 +40,7 @@ const ChatWithInstructions: FC<
user: [],
bot: [],
});
const [modelName, setModelName] = useState({});
const [modelName, setModelName] = useState<ModelNameMap>({});
const [provider, setProvider] = useState("");
const [localContext, setLocalContext] = useState(null);
const [agreeText, setAgreeText] = useState(null);
Expand All @@ -43,7 +49,7 @@ const ChatWithInstructions: FC<
const [readInstructions, setReadInstructions] = useState(
artifactsInput?.jump_instructions ? true : false
);
const { updateModelInputs } = useContext(CreateInterfaceContext);
const { updateModelInputs, modelInputs } = useContext(CreateInterfaceContext);
const { get, post, response, loading } = useFetch();
const { user } = useContext(UserContext);
const location = useLocation();
Expand Down Expand Up @@ -140,6 +146,24 @@ const ChatWithInstructions: FC<
bringDistinctContextAndModelInfo();
}, []);

useEffect(() => {
finishConversation &&
!("model_info" in modelInputs) &&
updateModelInputs({
...modelInputs,
model_info: {
provider: provider,
model_name: modelName[provider]["model_name"],
},
});
}, [finishConversation]);

useEffect(() => {
if ("chat_history" in modelInputs) {
setFinishConversation(true);
}
}, [modelInputs]);

return (
<>
{callLoading || loading ? (
Expand Down Expand Up @@ -241,4 +265,4 @@ const ChatWithInstructions: FC<
);
};

export default ChatWithInstructions;
export default ChatRandomWithInstructions;

0 comments on commit 8a46375

Please sign in to comment.